Skip to content

Using custom html elements with RehypeStringify #136

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

You must be logged in to vote

Heya @vritant24! 👋

The error is happening because custom-element is not a node type in hast https://github.com/syntax-tree/hast
Based off your previous question https://github.com/orgs/rehypejs/discussions/135
I'm assuming your intent is to serialize an HTML custom element.

If so a few ideas:

  1. When inserting the node, use the Element type from @types/hast to ensure it is the right structure. (see: https://www.npmjs.com/package/@types/hast)
  2. A valid hast Element will have a type: 'Element' and tagName: 'custom-element'. (see https://github.com/syntax-tree/hast#element)
  3. Rather than inserting a hast node in the middle of mdast consider either:
    • turning your plugin into a rehype plugin, and ru…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vritant24
Comment options

Answer selected by vritant24
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