xoofx / xoofx/markdig

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

Open
#424 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
5.3k
Forks
510
Avg merge
8d 5h
Merged PRs (30d)
5

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the SoftlineBreakAsHardlineExtension and compare the named entry points LineBreakInlineParser.EnableSoftAsHard and LineBreakInlineRenderer.RenderAsHardlineBreak. Determine the intended parser-versus-renderer extension boundary and whether hard-line-break constructs should be cancelled; the issue is done when that behavior and implementation direction are agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.