Closed chenzhiguang closed 1 year ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
lib/src/markdown.dart | 53 | 68 | 77.94% | ||
<!-- | Total: | 117 | 132 | 88.64% | --> |
Totals | |
---|---|
Change from base Build 3446153575: | -0.7% |
Covered Lines: | 1286 |
Relevant Lines: | 1366 |
This proposal is not a prototype, it is fully functional.
Can we have a look at it? I believe it is a good one.
This is actually pretty cool. But I would suggest doing it in smaller steps.
Like:
- Deprecate markdownToHtml(), use List.toHtml() instead.
That could be a PR on it's own. And it's much easier to get a review if it's not mixed with many other changes.
4.
blockSyntaxes
andinlineSyntaxes
options ofDocument
class vsextensions
option ofMarkdown
class.
I think this is an interesting idea. How far down this rabbit hole would we want to go.
At the extreme end we could make all the BlockSyntax
and InlineSyntax
implementations private, and completely forbid injection of custom syntaxes. It would make the package less flexible, but perhaps limit the number of bugs.
Like, right now the ordering of various syntaxes might affect how something is parsed. Or am I wrong?
Thank you for reviewing. Yes, this proposal generally demonstrates the idea and proof of concept. We should definitely break it into smaller pull requests.
Usage example of the new implementation
Major change
1. Deprecate
Document
, useMarkdown
insteadWith the current
Document
implementation, if a user wants to have only some syntaxes enabled, the only way to achieve that is set bothwithDefaultInlineSyntaxes
andwithDefaultBlockSyntaxes
tofalse
and pass in the desired syntaxes throughblockSyntaxes
andinlineSyntaxes
, it is tedious also easy to make mistakes, for example the order of syntaxes matters, you can not putInlineHtmlSyntax
afterEscapeHtmlSyntax
,ParagraphSyntax
must be the last block syntax etc.2. Deprecate markdownToHtml(), use List.toHtml() instead.
We have to maintain these tens of parameters which will be passed to
Markdown
class if we keep themarkdownToHtml()
function, alsoList<Node>.toHtml()
is more elegant.3. Deprecate
ExtensionSet
, useMarkdown
factory constructors instead.4.
blockSyntaxes
andinlineSyntaxes
options ofDocument
class vsextensions
option ofMarkdown
class.They do not make a big difference, just make it simpler to pass in custom syntaxes.