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

Render Markdown Codeblocks that contain code #2880

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

RomneyDa
Copy link
Collaborator

@RomneyDa RomneyDa commented Nov 12, 2024

Description

Fixes markdown codeblock rendering when they contain code

Approach

Detect the beginning of markdown code blocks and replace their ```s with ~~~s

People will be copying the code block with no backticks in the vast majority of cases anyways, not the entire generated output

Notes

Benchmarked at sub-millisecond or around 1ms for longer outputs

Doesn't work if language isn't specified in codeblocks, but usually it is
Doesn't work if tildes or more than 3 backticks are used in top-level markdown block, which is an extreme edge case

I wrote a version that does achieve that and included commented out, didn't use for performance/complexity concerns. It essentially predicts if it's another start/end codeblock based on if there's a new line after the ticks or not, but it doesn't work well mid-generation

Checklist

  • The relevant docs, if any, have been updated or created
image

Copy link

netlify bot commented Nov 12, 2024

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit c419d15
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/6732c7337680630008e80d10

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