New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formalize extensions support; add inline HTML support #44
Formalize extensions support; add inline HTML support #44
Conversation
if (document.extensions.contains('fenced-code-blocks')) { | ||
blockSyntaxes.add(const FencedCodeBlockSyntax()); | ||
} | ||
blockSyntaxes.addAll(standardBlockSyntaxes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way "extensions" or "plug-ins" work for InlineSyntaxes is that the parser pulls them from the document, which the public API can mutate. Outside code can just add in new objects that implement InlineSyntax.
I'm not sure if that's a great API or not—I lean towards not since it exposes an awful lot about how the parser is implemented—but I think it would be good for block syntax to be consistent with it.
You could either also add a blockSyntaxes
field to Document, or remove inlineSyntaxes
and use extensions for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I'm not crazy about exposing the innards. It's also unfortunate that the order of the syntaxes matters (maybe not so much with the block-level ones), because then the user can't insert their syntax in the middle.
I'll stick with how they work for InlineSyntaxes. Adding a blockSyntaxes
field to Document. I can change the API back if we need to later.
Thanks for the review, @munificent ! I've switched from strings to just objects, and I think its much cleaner now. Still not perfect, but at least consistent... let me know what you think. |
@srawlins would you want to rebase against master? |
I think I did... recently |
Or do you mean in the commit history? No I'll squash before merging. But maybe commit history is good for review for now. |
]; | ||
|
||
BlockParser(this.lines, this.document) { | ||
_pos = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize this at the declaration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Two nits, but 👍 |
Oh, and don't forget to update the CHANGELOG, adjust the version in the pubspec if needed, etc. |
522116d
to
8639667
Compare
c0ea754
to
9e4c2a6
Compare
Thanks for the review. This starts 0.9.0-dev, which will be unstable for a few more commits, methinks. |
Formalize extensions support; add inline HTML support
Fixes #18 and #43
I formalized support for Markdown extensions with an
extensions
optional parameter onmarkdownToHtml()
andnew Document()
.I then marked
fenced-code-blocks
as an extension (as they are), which serves as the block extension example, and added support for inline HTML (part of CommonMark 0.22), which serves as the inline extension example (and fixes #18).The support for inline HTML is not fantastic. There seems to be a big desire for this package to be performant. Until benchmarking is more mature, I used a very very cheap (presumably), very very liberal HTML pattern. This extension is called
inline-html
.