Is it possible to style EBNF

+1 vote
asked Jan 5, 2023 in Question / help by jack.burridge (120 points)

If we had the following diagram:

digit = "0" | "1"; 

Would it be possible to make the "0" red?

commented Nov 21, 2023 by The-Lu (67,080 points)

Hi J., and all,

Currently, we can change the color of all the text, as:

element {
  fontcolor red
digit = "0" | "1"; 

It that can help,

2 Answers

0 votes
answered Jan 5, 2023 by Todd Musheno (2,680 points)

That is not a thing in vanilla ebnf, although we could define an extension...

Could you post an example of what you think the syntax should be?

I think something like the following could work for syntax, but also think its ugly:

digit = <#red>"0"</red> | "1"; 
0 votes
answered Jan 5, 2023 by The-Lu (67,080 points)

Hello J., and all,

Currently you can put colour only on note, as:

title Color test
digit = "0" (* <color:red>0</color> *) | "1"; 

If that can help, Enjoy,

commented Jan 6, 2023 by Todd Musheno (2,680 points)

Good catch, I see notes on other nodes in the wild all the time.

Annotated text nodes, I have never seen yet.

Maybe some background on there use case may be helpfull?

I don't think its a bad extension idea, but its not ebnf strictly (although I do see stuff like that in the wild where people add syntax to ebnf to fit there needs).