mirror of https://github.com/vuejs/vitepress
Moves the inline table_open rule into its own plugin file and adds a `markdown.tableTabIndex` option (default true) to disable it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>pull/5335/head
parent
6bbd04e0bf
commit
bffe1e1412
@ -0,0 +1,14 @@
|
|||||||
|
import type { MarkdownItAsync } from 'markdown-it-async'
|
||||||
|
|
||||||
|
// adds tabindex="0" to tables so they are focusable and can be
|
||||||
|
// scrolled with the keyboard when they overflow horizontally
|
||||||
|
export const tablePlugin = (md: MarkdownItAsync) => {
|
||||||
|
const tableOpen = md.renderer.rules.table_open
|
||||||
|
md.renderer.rules.table_open = function (tokens, idx, options, env, self) {
|
||||||
|
const token = tokens[idx]
|
||||||
|
if (token.attrIndex('tabindex') < 0) token.attrPush(['tabindex', '0'])
|
||||||
|
return tableOpen
|
||||||
|
? tableOpen(tokens, idx, options, env, self)
|
||||||
|
: self.renderToken(tokens, idx, options)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue