vitepress
vitepress copied to clipboard
Regression: #3932 breaks chaining of table_open markdown.it rules
Describe the bug
I am using a markdown-it plugin to add classes to <table> tags. This was broken by #3932.
If you look at: https://github.com/vuejs/vitepress/pull/3932/files#diff-332834eb76757b8e31926e411cef34f7207564d0bf5fd00a185b41d97b3403bf
md.renderer.rules.table_open = function (tokens, idx, options, env, self) {
return '<table tabindex="0">\n'
}
This breaks the chaining of any other modifications to the table_open rule. My understanding is that you should use the methods on token to modify the token and then chain to the existing rule. This post has a decent description: https://publishing-project.rivendellweb.net/customizing-markdown-it/#adding-classes-to-list-and-list-items
It looks like the overriding of math_blocks further down in the file does chain the original renderer.
Reproduction
In config.mts
import markdownItClass from '@toycode/markdown-it-class'
...
export default defineConfig({
...
markdown: {
config: (md) => {
md.use(markdownItClass, {table: ['table', 'table-striped']})
},
},
})
Expected behavior
vitepress markdown.it plugin doesn't break other markdown.it plugin
System Info
System:
OS: Windows 11 10.0.22631
CPU: (16) x64 Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz
Memory: 9.01 GB / 31.75 GB
Binaries:
Node: 20.16.0 - C:\Program Files\nodejs\node.EXE
npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.5.0 - C:\Program Files\nodejs\pnpm.CMD
Browsers:
Edge: Chromium (127.0.2651.74)
Internet Explorer: 11.0.22621.3527
Additional context
No response
Validations
- [X] Check if you're on the latest VitePress version.
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
#4082 should fix this 👀
#4082 should fix this 👀
Agreed - sorry, I looked at open issues, but I didn't think to look at open PRs.
It looks like this PR has been open through several releases, is there anything I can do to support getting this into the next release?