I'm trying to render LaTeX strings in a React project.
Although I use the react-mathjax
React components, I want to get an HTML string made from the LaTeX strings in order to concatenate it and the other strings and set it by dangerouslySetInnerHTML.
My current code I tried
Sample cod here
- LaTeX strings are given as strings
- Make an empty DOM
aDom
bydocument.createElement('span')
(in background. not in the document DOM tree.) - Render a LaTeX string by
ReactDOM.render
intoaDom
- After rendering, get a string by
aDom.innerHTML
or.outerHTML
Problem
The value of aDom.innerHTML
(or .outerHTML
) is "<span><span data-reactroot=\"\"></span></span>"
(almost empty)
although aDom
has a perfect tree that MathJax generated.
Briefly,
aDom
:aDom.outerHTML
:
Question
How can I get the 'correct' HTML string from aDom
above?