Combining inline and block behaviour for markdown comments

Using the unmodified code for block commenting in the markdown parser, commenting only spans multiple lines if <!-- comes at the very beginning of the line. However, while I want commenting to be able to span multiple lines, I also want it to behave more like inline commenting, where the commenting section can start mid-line and also ends at --> (unlike the current block commenting which continues until the end of the last line).

I’ve tried to find ways of combining inline and block commenting, as well as ways of allowing inline elements to span multiple lines, but have been unsuccessful so far. Is there any way to have inline comments be able to span multiple lines? Or maybe there’s another approach I could take I’m not seeing?

Any advice would be greatly appreciated

Inline elements can span multiple lines in their parent block. But because Markdown divides the input into blocks before it does any inline parsing, you can’t make inline elements continue beyond what would be the end of the block (such as a blank line).

1 Like