Issues using a syntax tree with stringify #107
-
I am wanting to create two outputs (doc and toc). So I am approaching this by creating a tree that I then pass to two different processors. However my processor is not accepting my tree:
I am using this md as sample What is the proper way to split above? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Can you expand on this?
What do you mean? could you share a codesandbox with an example? (this is a good starting point https://codesandbox.io/s/remark-rehype-debug-4cz8v) |
Beta Was this translation helpful? Give feedback.
-
Ah thanks for sandbox link - https://codesandbox.io/s/remark-rehype-debug-forked-etych So I am wanting to have a table of contents that is separate - I already have all the code to render a toc from a tree. So what I am wanting to do is to 1) create a tree then 2) using that tree create the main html and also pass that tree to my toc builder. In the sandbox commented out at bottom I have a working example. How can I take that example and end up with the syntax tree AND the final html in a way that minimizes processing. |
Beta Was this translation helpful? Give feedback.
-
A couple problems:
see: https://codesandbox.io/s/remark-rehype-debug-forked-4fybi?file=/src/index.js for an example of how this comes together |
Beta Was this translation helpful? Give feedback.
-
Ah thank you. All trees are not alike :) |
Beta Was this translation helpful? Give feedback.
A couple problems:
stringify
doesn't run transforms,remark-rehype
is a transform, meaning in your example it is trying to turn a markdown tree into HTML text without having converted to an HTML tree. The overall flow is documented at https://github.com/unifiedjs/unified#description, to make this workrun
is needed to apply the transform.stringify
is not a promise, calling.then
will cause an errorsee: https://codesandbox.io/s/remark-rehype-debug-forked-4fybi?file=/src/index.js for an example of how this comes together