feat(editor): add best-effort rendering of markdown snippets in preview #4856
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.
Best-effort rendering of markdown snippets in preview
This PR implements a temporary solution for rendering
<Markdown />snippet tags in the editor's preview pane while waiting for full file resolution support (PR #4774). It analyzes the difference betweenrawMarkdownandmarkdownfields from FDR to infer what each snippet resolves to, then displays the resolved content in preview only.What was the motivation & context behind this PR?
Currently,
<Markdown />snippet tags appear as raw tags in the preview pane. This PR provides an interim rendering solution by:<Markdown />tags and their resolved content using surrounding contextLink to Devin run: https://app.devin.ai/sessions/a42cecbe41e3416690856255590142ca
Requested by: Sarah Bawabe ([email protected]) / @sbawabe
How has this PR been tested?
Critical testing required:
<Markdown />tags: Verify the algorithm correctly matches tags to resolved content<Markdown />tagsImplementation details worth reviewing:
New file:
bestEffortMarkdownSnippets.ts/<Markdown\s*(?:[^>]*?)\/>/gto find self-closing tagsModified file:
page.tsxpage.rawMarkdown !== page.markdownpreviewMdxwith resolved snippets for preview renderingrawMarkdown(via separate code path)Known limitations: