progsource / maddy

C++ Markdown to HTML header-only parser library
MIT License
194 stars 39 forks source link

Code Blocks #29

Open slzatz opened 4 years ago

slzatz commented 4 years ago

First of all, thanks for this work -- it's very helpful.

Currently code blocks are supported with three backticks but the original markdown spec is that 4 spaces or a tab at the beginning of a line mark a code block and this does not appear to be supported. There are a lot of markdown documents that employ that approach -- is it possible to support this syntax?

progsource commented 4 years ago

Sorry for my late reply.

So - it is possible to implement this with the current maddy version. It would need a new Block Parser (IndentedCodeBlockParser) - that one would have to check for the number of spaces at the beginnings of the line and should not directly stop on an empty line, but only if the line afterwards is not an indented block anymore. For that maybe also the Parser class would need to be able to go over one line twice - or the parsers need to be able to get a look-ahead. Another solution would be to stop the IndentedCodeBlockParser only after two empty lines.