Description
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:
Subsequently, the actual highlighting implementation operates on the bare 1,3 format rather than the documented {1,3} syntax:
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 consttransformers
(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.
System Info
System:
OS: macOS 15.0.1
CPU: (8) arm64 Apple M2
Memory: 95.88 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.13.0 - ~/.nvm/versions/node/v22.13.0/bin/node
npm: 11.1.0 - ~/.nvm/versions/node/v22.13.0/bin/npm
pnpm: 9.15.4 - ~/.nvm/versions/node/v22.13.0/bin/pnpm
Browsers:
Chrome: 135.0.7049.96
Safari: 18.0.1
Additional context
I will create a PR right away.
Validations
- Check if you're on the latest VitePress version.
- Follow our Code of Conduct
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.