Skip to content

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
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension README.md preview markdown codeblock language detection

3 participants