Repository navigation
Show the full language name on a code block - #97
Merged
Merged
Conversation
The label read the language from the code element's class with \w+, so it stopped at the first character outside [A-Za-z0-9_]: a c++ or c# block was labelled C and an objective-c block OBJECTIVE. It now takes everything up to the next space.
Owner
|
Thanks @rudycelekli — clear write-up and a solid regression test. Merging! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bug
The language label on a code block in chat replies and note previews is cut short for common languages. A
```c++or```c#block is labelled C, and```objective-cis labelled OBJECTIVE.CodeBlockreads the language from thelanguage-…class with/language-(\w+)/.\wstops at+,#and-.Fix
/language-(\S+)/takes the whole class token. remark puts the first word of the fence's info string there, so the label now matches what was written after the backticks. Blocks with a plain language name such asjslook the same as before.Test
apps/web/test/markdown-code.test.tsrendersMarkdownwithreact-dom/serverand reads the label forc++,c#,objective-candjs.cd apps/web && npx vitest run test/markdown-code.test.tsexpected 'c' to be 'c++'.npm run typecheckand biome are clean inapps/web.