@mmeix it looks to me at first glance that you could make some rules span = <span> val </span> paragraph = <p> val </p> val = paragraph* | span* | val [editS: added stars to p and span in val]
the last rule allows recursion, which can infinitely nest spans or p's
notice how i defined the rigid components of the grammar on the right-hand side, with my variable, and how i use variable names only on the left-hand side.
That looks like a good recipe. Thanks!
@mmeix http://instaparse-live.matt.is/#/-M16TrdGzPQ0FFLRyCyd/v1
i had to make sure it works before setting you out
notice how there can be multiple valid parses with the recursion now.
you'll probably need to be creative with the output to get rid of tags you don't need 😃 i forget exactly how we would delete unnecessary strings in the grammar itself, there's a way with rules i think, it might just be mathematical though lol
Getting rid of tags is done by enclosing them with <…>
Thanks for the gist!
Now I’m thinking, if it would be possible to get a general solution without enumerating all possible tags (span, p , …). It would need to somehow remember the tag name until its closing cousin arrives
Didn’t know http://instaparse-live.matt.is ! Great tool!