Hi!
I’m trying to extend markdown syntax in Lezer/CodeMirror for an app I’m working on.
The new syntax is intended for math in display mode, and should behave a lot like fenced code blocks - the difference being the delimiters ($$
instead of ```
) and that the delimiters are not required to span their own line (but they must start/end the line they appear on, correspondingly).
In particular, this syntax may contain any amount of line breaks (as long as they’re between the delimiters).
I’ve implemented a minimal example in this playground.
I’m encountering two problems:
First, as you can see in the playground, the parser seems to only parse lines with an empty line above - I’m assuming these are the first lines of each block.
This makes sense, as the parsing is done using blockParser
s. However, built-in structures such as actual FencedCode
blocks don’t seem to adhere to this limitation, and work without an empty line above (this is also seen in the playground) - I can’t seem to replicate this behvaior in my new syntax.
If it’s of any value, lezer-markdown
’s docs suggest using eager leaf block parsers for constructs similar to code blocks (link), which is why I chose them for the implementation.
The second problem is that syntax highlighting inside these blocks using parseMixed()
doesn’t seem to work. For reference, I’ve included in the playground an inline-math syntax (with single $
delimiters), for which it does seem to work.
What am I doing wrong?
As always, thanks for your work and your time!