UNPKG

@x-govuk/govuk-eleventy-plugin

Version:

Write documentation using Markdown and publish it using GOV.UK styles

19 lines (17 loc) 525 B
/** * Render a table with `tabindex` to enable keyboard scrolling * * @param {import('markdown-it')} md - markdown-it instance */ export function tableRules(md) { const { rules } = md.renderer const defaultRenderer = rules.table_open || function (tokens, idx, options, env, self) { return self.renderToken(tokens, idx, options) } rules.table_open = (tokens, idx, options, env, self) => { tokens[idx].attrPush(['tabindex', 0]) return defaultRenderer(tokens, idx, options, env, self) } }