Skip to content

Why the nested directives are parsed correctly but their HTML does not render? #113

Answered by wooorm
reypm asked this question in Q&A
Discussion options

You must be logged in to vote

reverse doesn’t change to a depth-first tree-traversel, so it doesn’t do what you want.

Your problem is that you transform the tree.
While transforming the tree, by setting hChildren, you are saying: ignore everything, use my hChildren instead.

Hopefully, you don’t care about the div, and can apply the class to the section instead.
Then it just works:

  node.data.hProperties = {
-   className: ['sc-card']
+   className: ['sc-card', node.name + '-content']
  }

- node.data.hChildren = [
-   {
-     type: 'element',
-     tagName: 'div',
-     properties: {
-       className: node.name + '-content'
-     },
-     children: node.children.map(toHast)
-   }
- ]

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@reypm
Comment options

@wooorm
Comment options

Answer selected by reypm
@reypm
Comment options

@reypm
Comment options

@ChristianMurphy
Comment options

@reypm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants