BNF Rules and Syntax Highlighters #119
Unanswered
tajmone
asked this question in
The ALAN Manual
Replies: 1 comment 3 replies
Fair point. I'll try to remember to update that in the manual. For sake of correctness. Otherwise I don't have much to add here. My only concern is that EBNF block should have a separate rendering so that they are visually different. There's no need for highlighting, so whatever is the easiest to achieve that is fine by me. (A role sounds like the easiest route, but you're the expert.) |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
@thoni56, while sifting through the dev style preview docs, and updating them, I noticed that BNF rules are currently defined as code blocks in The ALAN Manual (and possibly in some ALAN Design Docs):
I now remember that my original intention was to provide a BNF syntax for all highlighter — Highlight already has one, and for the FOPub toolchain I was planning to create one (see #38).
But now we have multiple syntax highlighters being used in this project, and most of them (i.e. all except Highlight) don't support BNF grammars, which means they'll simply not highlight the block, which would then be just a verbatim block.
But even when they do highlight the BNF rule (e.g. Highlight), we didn't define any custom them for it, so it will show as a two-coloured block anyway (background and foreground text only).
I'm wondering if we shouldn't just convert those blocks so that
bnfbecomes a role (class) rather than a language. This would require tweaking the Sass sources (no big deal) and the XSL stylesheet (not a huge deal either).Alternatively, I could just go ahead with our original intention of providing syntax highlighting support for BNF, which would result in subtle colour differences (or bold vs normal) being shown in the block, according to tokens types:
Since BNF grammars are really simple, it wouldn't involve much work at all (I've also created the one for Highlight, if I remember correctly).
But it's worth noting that these BNF rules in the ALAN Manual are actually EBNF grammars, not BNF! Not trying to pedant here, my concern is that if the official highlighter were to introduce a BNF syntax definition, they might end up clashing with our, that's all.
All reactions