Closed CrockAgile closed 2 years ago
😍 🤩 This is so cool!
As far as your concerns about the danger of running into broken graphs when the grammar and the mermaid spec don't agree, my take is that we're good. I appreciate the the mermaid Display is opt in so we won't break the implicit impl Display for anyone. And imo this is really a documentation nicety (a very nice nicety) and so I think we can merge it as is because it has immediate benefit and if some sharp edges are eventually spotted we can address them then.
One note, it looks like your branch is out of date with main, I believe if you sync up with it again your build will succeed.
This adds mermaid output for parse trees. Honestly, not sure if useful enough to warrant being merged. But it sure is nice to include in github docs, such as PRs!
Implementation
each node gets assigned a unique, auto incrementing ID. But instead of displaying that ID in the Mermaid diagram, use the
Term
string.Dangers
I do think this draft implementation can produce invalid input. Because BNF allows for arbitrary tokens in
Term
s, Mermaid expects some of those characters to be escaped.I am not sure if the right next step is to build a "fully compliant" Mermaid filter layer, or maybe just accept that some grammars may not build parse trees that Mermaid can parse.