markdown
markdown copied to clipboard
Make default syntaxes public
Is there a reason that the default inline syntaxes are private?
https://github.com/dart-lang/markdown/blob/782b1803a29aa964410d93b4437d5d1efa47f6b4/lib/src/inline_parser.dart#L26
Imagine that I want the defaults, but I want to add my own syntax either as top priority, or bottom priority. With public defaults, that's as easy as:
inlineSyntaxes: [
myTopPrioritySyntax,
...defaultInlineSyntaxes,
myBottomPrioritySyntax,
]
But if the defaults are private then the developer has to dig through the source code to fine them, and then has to copy them over. There will be cases where that's still necessary, because sometimes a new syntax needs to be placed at a specific location in the priority list, but the most common case probably doesn't require that level of intervention.
Because the order matters, for example, if you put SoftLineBreakSyntax()
before LineBreakSyntax()
, some syntax might not work as expected, or it might lower the performance if you move them around freely.
But perhaps that shouldn't be the reason for making it private
I understand order matters - that's why I describe three cases in my original post:
- Add a syntax as top priority
- Add a syntax as bottom priority
- Add a syntax somewhere in the middle
Situation 3 will always require copying the list. But situation 1 and 2 wouldn't, and I would guess those two are the average.