-
Notifications
You must be signed in to change notification settings - Fork 139
Exploration: Marked + React Renderer #11279
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
Open
dhruvisompura
wants to merge
10
commits into
main
Choose a base branch
from
notebooks/react-renderer-for-markdown
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+812
−242
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
E2E Tests 🚀 |
seeM
previously approved these changes
Jan 8, 2026
Contributor
seeM
left a comment
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.
Code changes look great! I'll take it for a spin locally tomorrow morning, haven't had a chance yet
This reverts commit fde1ebd.
f36349b to
c10334c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow up to PR #11212 that explores being able to directly render React components from markdown as suggested by @seeM in this comment: #11212 (review)!
Right now we do Markdown → Tokens → HTML String → DOM, which means we're generating HTML strings and then parsing them back into the DOM. In this PR we now do Markdown → Tokens → React Elements. The main idea is to skip the intermediate HTML string step and work directly with React components. We use Marked to get the tokenized version of the markdown and then pass the tokens to a custom renderer which converts the tokens to the appropriate react component.
That said, there are still a few cases where we need HTML parsing. KaTeX (for LaTeX math) and our syntax highlighting both return HTML strings rather than tokens, so we still use
safeSetInnerHtmlfor those and convert the resulting DOM to React viadomToReact.tsxutility (this is pretty close to what we were doing prior to this change but we needed a parser that could better handle katex html unlikehtmlParser.ts).The
TokenMarkdownRendererclass handles the token-to-React conversion, with custom components likeKatexMath,SyntaxHighlightedCode, andRawHtmlfor the more complex rendering scenarios.One benefit of this approach as mentioned by @seeM is allowing us to easily create/explore richer markdown output.
Release Notes
New Features
Bug Fixes
QA Notes
@:positron-notebooks