Introduce richtext-markdown as a generic Markdown renderer #129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Markdown unfortunately does not have a universally agreed standard. Different flavors, libraries can parse Markdown content in their own ways.
richtext-commonmark
usesCommonmark
spec and parser to convert any given markdown String into an intermediate Abstract Syntax Tree that has been defined internally since its release.The idea has always been to extract this ASTNode structure out of this module to enable custom parsing logic to be supplied from outside, and make
richtext-commonmark
only responsible for rendering the given tree usingrichtext-ui
.This change introduces a new module named
richtext-markdown
which is actually just a rename of the existingrichtext-commonmark
. This new module also exposes its internalAstNode
APIs to enable other modules to render their own AstNode structures.richtext-commonmark
becomes a helper module which can parse any given string into an AstNode viaCommonmarkAstNodeParser
. Also, it still provides aRichTextScope.Markdown
function that simply does the conversion asynchronously, then calls theMarkdown(AstNode)
flavor fromrichtext-markdown
.