Skip to content

Commit aadc517

Browse files
fix: don't hardcode tabindex attr in table renderer (#4082)
Co-authored-by: Divyansh Singh <[email protected]>
1 parent a8a1800 commit aadc517

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/node/markdown/markdown.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,13 @@ export async function createMarkdownRenderer(
246246
)
247247
.use(lineNumberPlugin, options.lineNumbers)
248248

249+
const tableOpen = md.renderer.rules.table_open
249250
md.renderer.rules.table_open = function (tokens, idx, options, env, self) {
250-
return '<table tabindex="0">\n'
251+
const token = tokens[idx]
252+
if (token.attrIndex('tabindex') < 0) token.attrPush(['tabindex', '0'])
253+
return tableOpen
254+
? tableOpen(tokens, idx, options, env, self)
255+
: self.renderToken(tokens, idx, options)
251256
}
252257

253258
if (options.gfmAlerts !== false) {

0 commit comments

Comments
 (0)