Conversation
|
@szymonograbek Thank you! I will take a look these days. |
LouisDvr
left a comment
There was a problem hiding this comment.
I'm excited by the support for plugins so I had a look at that part of the PR to try and fasten its inclusion in the lib. Thanks for doing it!
As I commented, I think considering remark-parse like an optional plugin leads to problems so I would recommend forcing its usage
Also, this comment in the original issue even recommends to drop suggested plugins and let users use whichever plugin they need. It could reduce the bundle size to avoid importing remark-gfm in all cases but I wonder if it wouldn't be misleading to say the lib support GFM (because it includes the appropriate renderers) while still requiring users to pass the plugin manually. Wdyt @szymonograbek and @imwithye ?
Finally, I think adding a mermaid example isn't really linked to adding support for custom plugins, though originating from the same discussion, so it would be cleaner to put it in a separate PR to avoid bloating this one and ease the review and acceptance or not of each subject (mermaid example represents more than 98% of the changed lines)
| }: MarkdownProps) => { | ||
| const tree = useMemo(() => parser.parse(markdown), [markdown]); | ||
| const processor = useMemo(() => { | ||
| return unified().use(remarkPlugins); |
There was a problem hiding this comment.
And here
| return unified().use(remarkPlugins); | |
| return unified().use(remarkParse).use(remarkPlugins); |
| import { Styles, mergeStyles } from "./themes/themes"; | ||
|
|
||
| const parser = unified().use(remarkParse).use(remarkGfm); | ||
| const defaultRemarkPlugins: PluggableList = [remarkParse, remarkGfm]; |
There was a problem hiding this comment.
I think remarkParse shouldn't be included in the default plugins and the lib should rather use it by default because
- users can pass an empty array, which would lead to a runtime error (
TypeError: Cannot "processSync" without "Parser") remarkParseis the official remark parser so users will always want to use it when customizing the plugins list so using it by default would reduce the boilerplate
This would give
| const defaultRemarkPlugins: PluggableList = [remarkParse, remarkGfm]; | |
| const defaultRemarkPlugins: PluggableList = [remarkGfm]; |
I've though about it and I agree, we should keep
Sure, I've removed it from this PR |
|
Thank you for your PR! I will review it this week. Overall, it looks good to me! |
|
Hey @imwithye, I hope you're doing well. Did you have time to have a look to this PR? It would really help using this lib for a lot of use-cases which require patching it for the moment. If you need anything to speed things up, I'd be happy to provide you with any assistance I can. Thanks again for this awesome lib! |
|
Hey @szymonograbek, I hope you're doing well! I reached to @imwithye regarding the maintenance of this repo. He doesn't currently have enough time for it but added me as collaborator on this repo so I can help by reviewing and merging PRs. Do you wish to finish the work you've started on this PR? If so, I think you can do what we've talked about regarding Regarding Btw, having a look to the code to remember what was done here, I've noticed you disabled the I'd understand you don't have time anymore for this and will happily do the last changes if you don't want to do them or don't answer in the next few weeks Have a nice day! |
|
@LouisDvr TBH I don't have much free time to finish this and I no longer work in the project that needed this change, so feel free to take it over |
No problem! I'll apply the last changes Thank you very much for the work you've put in this contribution 🙏🏼 |
|
Closing since work has been continued in PR #60 |
## 📝 Description This PR adds support for remark plugins to allow users take advantage of the remark ecosystem and extend the lib's behavior (when using plugins that add new nodes, users will have to inject the needed renderers using the `customRenderers` prop). It finishes the work started in PR #58 by [szymonograbek](https://github.com/szymonograbek). It also adds a section in the `README` file to explain how to use plugins with the lib. ## 📌 Related Issue (Optional) Link: #43 ## 📷 Screenshots (Optional) Example using the `remark-cjk-friendly` plugin. | Before | After | | ------ | ------ | | <img height="550" src="https://github.com/user-attachments/assets/fcb98d17-7065-4c4e-a369-a593c381c439" /> | <img height="550" src="https://github.com/user-attachments/assets/45dfbd55-ef12-41fb-afba-c7d85c9a3f4f" /> | ## 📄 Test Markdown File (Optional) File `05_cjk_plugin_example.md` included in the PR ## ✅ Checklist - [x] My PR title follows the Conventional Commit format (e.g. `feat:`, `fix:`, `chore:`) - [x] This PR addresses the related issue (if applicable) - [x] I have attached a sample Markdown file (`.md`) used for testing - [x] I have attached at least one screenshot of the rendered output (light and/or dark mode preferred) - [x] I have run `pnpm run lint:fix` to fix formatting and lint errors - [x] I have tested the changes in the example app (`pnpm i && cd example && pnpm i && pnpm run ios`) --------- Co-authored-by: Szymon Ograbek <szymon.ograbek2@gmail.com>
📝 Description
This PR adds support to pass plugins to the processor, so we can use i.e.
rehypeParseandrehypeRemarkto parse HTML to markdown. I've added temporal samples as typescript files to test this locally, if this PR will be accepted then I'll move them to the rest of markdown files.📌 Related Issue
Link: #43
📷 Screenshots
Parsed HTML:

✅ Checklist
feat:,fix:,chore:).md) used for testingpnpm run lint:fixto fix formatting and lint errorspnpm i && cd example && pnpm i && pnpm run ios)