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

Improve extension README preview markdown codeblock language detection #205329

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

RedCMD
Copy link
Contributor

@RedCMD RedCMD commented Feb 16, 2024

Fixes #205328

after attempting to match a language alias against the whole line (and failing)
it will fall back to attempting to match only the initial (whitespace separated) language name

the intention for this is for my extension
json textmate is a subset of normal json
I wanted to put a codeblock in displaying some json textmate code
but if my extension isn't installed, I wanted it to default back to normal json
which is what Github and the builtin Markdown extension does
but the extension README.md preview does not

lang.split(/\s+|:|,|(?!^)\{|\?]/, 1)[0]
splits the language line once on one of the following symbols :,{?
then returns the first section
(leading whitespace is already stripped from the lang line)

Copy link
Collaborator

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mjbvz mjbvz merged commit 7560c3d into microsoft:main Feb 20, 2024
6 checks passed
@RedCMD RedCMD deleted the improve-codeblock-detection branch February 20, 2024 18:13
@microsoft microsoft locked and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
3 participants