Skip to content

Tag name and attributes are not taken into account when using Hastscript #1275

Closed Answered by ChristianMurphy
azat-io asked this question in Q&A
Discussion options

You must be logged in to vote

@azat-io an issue I'm seeing, you are mixing the HTML and Markdown syntax tree types.

If you want to work on the HTML, write a Rehype plugin and work with the HTML AST (hast). https://unifiedjs.com/learn/
Also some of the previous community ideas in https://github.com/orgs/mdx-js/discussions/1948

remark plugins should only have markdown constructs (mdast), if you want to specify different HTML types for markdown constructs use node.data.hName as documented in https://github.com/syntax-tree/mdast-util-to-hast#fields-on-nodes
That said, a rehype plugin sound like a better for what you are describing.

Replies: 2 comments

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 ChristianMurphy
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