Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: #3932 breaks chaining of table_open markdown.it rules #4239

Open
4 tasks done
dwgray opened this issue Sep 29, 2024 · 2 comments
Open
4 tasks done

Regression: #3932 breaks chaining of table_open markdown.it rules #4239

dwgray opened this issue Sep 29, 2024 · 2 comments
Labels
build Related to the build system

Comments

@dwgray
Copy link

dwgray commented Sep 29, 2024

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

@dwgray dwgray added the bug: pending triage Maybe a bug, waiting for confirmation label Sep 29, 2024
@brc-dd
Copy link
Member

brc-dd commented Sep 30, 2024

#4082 should fix this 👀

@brc-dd brc-dd added build Related to the build system and removed bug: pending triage Maybe a bug, waiting for confirmation labels Sep 30, 2024
@dwgray
Copy link
Author

dwgray commented Sep 30, 2024

#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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Related to the build system
Projects
None yet
Development

No branches or pull requests

2 participants