Skip to content

Any possible to apply default className for table jsx in mdx? #1740

Closed Answered by JounQin
JounQin asked this question in Q&A
Discussion options

You must be logged in to vote

I write a small remark plugin to support jsx table in .mdx like html table in .md.

export const remarkJsxTable: Plugin<[], Root> = () => (ast) => {
  visit(ast, 'mdxJsxFlowElement', (node) => {
    if (
      node.name &&
      ['table', 'thead', 'tbody', 'tfoot', 'tr', 'th', 'td'].includes(
        node.name,
      ) &&
      node.data?._mdxExplicitJsx
    ) {
      delete node.data._mdxExplicitJsx
    }
  })
}

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JounQin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants