Conversation
* Bump to react-markdown 10.0.0, bump all plugins to latest versions * component_map: "codemap" with "pre" for simpler handling of inline vs code block * Add new `rx.markdown.plugin` function to allow easily loading remark and rehype plugins * Add new `MarkdownWrapper` since the new react-markdown doesn't accept css/className * Add `use_math`, `use_gfm`, `use_raw` and friends to customize default plugins BREAKING: children for textual components is now a bare string instead of a list of str
Greptile SummaryUpgraded react-markdown from 8.0.7 to 10.1.0 and modernized the markdown component architecture with several improvements:
Breaking change: Children for textual components are now bare strings instead of lists of strings Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant MarkdownWrapper
participant Markdown
participant Plugin
participant ReactMarkdown
User->>MarkdownWrapper: create(content, use_math=True, use_gfm=True)
MarkdownWrapper->>Plugin: Access plugin.math, plugin.gfm
Plugin-->>MarkdownWrapper: Return plugin Vars with imports
MarkdownWrapper->>MarkdownWrapper: Assemble remark_plugins array
MarkdownWrapper->>MarkdownWrapper: Assemble rehype_plugins array
MarkdownWrapper->>Markdown: create(content, remark_plugins, rehype_plugins, component_map)
Markdown->>Markdown: Process component_map (handle codeblock deprecation)
Markdown->>Markdown: Generate component map hash
Markdown->>Markdown: Create pre handler (extract from rest.children.props)
Markdown->>ReactMarkdown: Render with components and plugins
ReactMarkdown-->>User: Rendered markdown
|
There was a problem hiding this comment.
Additional Comments (2)
-
tests/units/components/markdown/test_markdown.py, line 147-149 (link)logic: Test expects
result["code"]but new implementation moved code block handling toresult["pre"](line 367 in markdown.py). Tests will fail - should test"pre"key instead. -
tests/units/components/markdown/test_markdown.py, line 154-156 (link)style: Using deprecated
"codeblock"in component_map - should be"pre"per the deprecation warning in markdown.py:304-311
4 files reviewed, 5 comments
|
@greptile-apps please re-review |
There was a problem hiding this comment.
Pull request overview
This pull request modernizes the Reflex markdown component by upgrading to react-markdown 10.1.0 and implementing a more flexible plugin architecture. The key changes include replacing "codeblock" with "pre" for code block handling, introducing a new Plugin API for easily loading remark/rehype plugins, and adding the MarkdownWrapper component with optional built-in plugins that can be toggled via props.
Changes:
- Upgraded react-markdown from 8.0.7 to 10.1.0 and all related plugin packages
- Changed component_map key from "codeblock" to "pre" for simpler inline vs block code handling
- Added new Plugin class and MarkdownNamespace with plugin accessor for dynamic plugin loading
- Added MarkdownWrapper with use_math, use_gfm, use_katex, use_raw, and use_unwrap_images props
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| reflex/components/markdown/markdown.py | Upgraded library, added Plugin class, MarkdownWrapper, and MarkdownNamespace; refactored code block handling from "codeblock" to "pre" |
| reflex/components/markdown/init.py | Updated export to use new markdown namespace |
| tests/units/components/markdown/test_markdown.py | Updated test expectations for "pre" mapping instead of "codeblock" |
| tests/units/components/typography/test_markdown.py | Updated import path to reflect new module structure |
| .github/workflows/check_outdated_dependencies.yml | Removed markdown plugin packages from outdated dependency ignore list |
| pyi_hashes.json | Updated hash for markdown.pyi |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* Updates for react-markdown 10.0.0 and associated reflex changes * Update markdown docs with info on plugins * fix misrendered nested code blocks in markdown examples * update deps * update pyproject.toml * Robust slugify of markdown header data You can now include nested markdown in headers and it will slugify it correctly using hast-util-to-string to properly extract recursively nested elements. Also includes a driveby fix for scroll-margin when the hosting banner is displayed.
rx.markdown.pluginfunction to allow easily loading remark and rehype pluginsMarkdownWrappersince the new react-markdown doesn't accept css/classNameuse_math,use_gfm,use_rawand friends to customize default pluginsBREAKING: children for textual components is now a bare string instead of a list of str
This depends on a related change in reflex-web, which will include some doc update on how to use the new
rx.markdown.pluginsinterfaceSample Code
Details