Skip to content
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

Introduce richtext-markdown as a generic Markdown renderer #129

Merged
merged 2 commits into from
Feb 10, 2024

Conversation

halilozercan
Copy link
Owner

Markdown unfortunately does not have a universally agreed standard. Different flavors, libraries can parse Markdown content in their own ways. richtext-commonmark uses Commonmark 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 using richtext-ui.

This change introduces a new module named richtext-markdown which is actually just a rename of the existing richtext-commonmark. This new module also exposes its internal AstNode 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 via CommonmarkAstNodeParser. Also, it still provides a RichTextScope.Markdown function that simply does the conversion asynchronously, then calls the Markdown(AstNode) flavor from richtext-markdown.

@halilozercan
Copy link
Owner Author

#123

@halilozercan halilozercan force-pushed the richtext-markdown branch 2 times, most recently from 682280c to 85ca816 Compare February 9, 2024 00:36
Markdown unfortunately does not have a universally agreed standard. Different flavors, libraries can parse Markdown content in their own ways. `richtext-commonmark` uses `Commonmark` 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 using `richtext-ui`.

This change introduces a new module named `richtext-markdown` which is actually just a rename of the existing `richtext-commonmark`. This new module also exposes its internal `AstNode` 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 via `CommonmarkAstNodeParser`. Also, it still provides a `RichTextScope.Markdown` function that simply does the conversion asynchronously, then calls the `Markdown(AstNode)` flavor from `richtext-markdown`.
@halilozercan halilozercan force-pushed the richtext-markdown branch 2 times, most recently from a4cd23b to 67865da Compare February 9, 2024 18:04
This change includes bunch of misc tech debt cleaning.

- Use Compose Multiplatform dependencies instead of Google's Compose artifacts
- Removed Previews from richtext-ui.
- Renamed CodeBlock platform files.
- Kotlin updated to 1.9.22
- Compose compiler update to 1.5.8
- Changed MarkdownSample to use CommonmarkAstNodeParser and do synchronous Markdown rendering.
@halilozercan halilozercan merged commit 29a94b4 into main Feb 10, 2024
2 checks passed
@halilozercan halilozercan deleted the richtext-markdown branch February 10, 2024 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant