markdig icon indicating copy to clipboard operation
markdig copied to clipboard

Preferred way to implement extensions? (parser vs renderer manipulation)

Open mlaily opened this issue 4 years ago • 0 comments

First question: What are the pros and cons of implementing extensions by manipulating the parser vs manipulating the renderer to obtain the same result? How to choose?

I have a specific case in mind: the SoftlineBreakAsHardlineExtension.

It's currently implemented by changing the parsing logic (using LineBreakInlineParser.EnableSoftAsHard), but it could also have been implemented by changing the renderer logic (using LineBreakInlineRenderer.RenderAsHardlineBreak)


Second question, that triggered the first one: SoftlineBreakAsHardlineExtension does not cancel the parsing of hard line break constructs (double space or backslash at the end of a line). It's strange to see a backslash disappear for nothing when this extension is enabled...

Would a PR be welcome to add an option doing that? (and if so, should it be done in the parsers logic, or the renderers logic? and should it be on by default for this extension?)

Thanks for your time.

mlaily avatar Apr 19 '20 19:04 mlaily