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

Merged
merged 9 commits into from
Nov 18, 2024
Merged

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 failed. Why did it fail? →

Name Link
🔨 Latest commit 9bf97e4
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/673ba0b1f28a38000853aa7a

sestinj
sestinj previously approved these changes Nov 18, 2024
@sestinj sestinj merged commit a9fd775 into main Nov 18, 2024
2 checks passed
@sestinj sestinj deleted the dallin/nested-md-code branch November 18, 2024 20:17
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.

2 participants