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

Open
opened 2026-01-29 14:34:56 +00:00 by claunia · 0 comments
Owner

Originally created by @mlaily on GitHub (Apr 19, 2020).

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.

Originally created by @mlaily on GitHub (Apr 19, 2020). 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#360