You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The feature appears to be working correctly. However, I've noticed that VitePress implements its own additional processing for the meta highlight functionality, which could potentially be replaced by Shiki's built-in transformerMetaHighlight.
The core issue that led to this being reported as a bug stems from how VitePress handles line number metadata. When syntax like {1,3} is used, the braces are stripped during processing and only the numbers are preserved in token.info:
This implementation discrepancy with the official documentation causes transformerMetaHighlight to fail when attempting to match the expected {1,3} pattern.
Reproduction
Fork and clone VitePress repo.
Comment attrsToLines() function (line 26 - 48), line 124 and line 155.
Add import of transformerMetaHighlight from @shikijs/transformers and use it in const transformers (line 43).
Run docs server and navigate to "Markdown Extensions - Line Highlighting in Code Blocks". The lines are not highlighted apparently.
Expected behavior
The line numbers meta inside the braces is expected to be matched instead of ones without brace.
shiki's transformerMetaHighlight can be used to implement the feature.
Describe the bug
The feature appears to be working correctly. However, I've noticed that VitePress implements its own additional processing for the meta highlight functionality, which could potentially be replaced by Shiki's built-in
transformerMetaHighlight
.The core issue that led to this being reported as a bug stems from how VitePress handles line number metadata. When syntax like {1,3} is used, the braces are stripped during processing and only the numbers are preserved in token.info:
https://github.com/vuejs/vitepress/blob/19faa16169b44f52bedf1401b4a97b2a8ffdeacb/src/node/markdown/plugins/highlightLines.ts#L45C5-L45C30
Subsequently, the actual highlighting implementation operates on the bare 1,3 format rather than the documented {1,3} syntax:
https://github.com/vuejs/vitepress/blob/19faa16169b44f52bedf1401b4a97b2a8ffdeacb/src/node/markdown/plugins/highlight.ts#L27C3-L27C68
This implementation discrepancy with the official documentation causes transformerMetaHighlight to fail when attempting to match the expected {1,3} pattern.
Reproduction
attrsToLines()
function (line 26 - 48), line 124 and line 155.transformerMetaHighlight
from@shikijs/transformers
and use it in consttransformers
(line 43).Expected behavior
The line numbers meta inside the braces is expected to be matched instead of ones without brace.
shiki's
transformerMetaHighlight
can be used to implement the feature.System Info
Additional context
I will create a PR right away.
Validations
The text was updated successfully, but these errors were encountered: