Comment support for katex
nmanumr opened this issue · 1 comments
nmanumr commented
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Affected packages and versions
rehype-katex@6.0.0
Link to runnable example
No response
Steps to reproduce
try the following equation in the markdown
$$
\begin{split}
f(-2) &= \sqrt{-2+4} \\
&= x % Test Comment
\end{split}
$$
with following processors
let processor = unified()
.use(markdown)
.use(math)
.use(remark2rehype)
.use(katex)
.use(document, {css: ['https://cdn.jsdelivr.net/npm/katex@0.13.13/dist/katex.min.css']})
.use(html);
Expected behavior
Comments should work properly
Actual behavior
The following warnings appear in the console:
LaTeX-incompatible input and strict mode is set to 'warn': % comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $) [commentAtEnd]
docs/maths-1/ch1/ex1.1/q1-i.md
3:1-8:3 warning KaTeX parse error: Expected & or \\ or \cr or \end at end of input: …ent \end{split} parseerror rehype-katex
Runtime
Node v14
Package manager
No response
OS
macOS
Build and bundle tools
Other (please specify in steps to reproduce)
nmanumr commented
In reality, newlines are being ignored in by toText method here: https://github.com/remarkjs/remark-math/blob/main/packages/rehype-katex/index.js#L42
If you use hast-util-to-string
instead of hast-util-to-text
the problem gets resolved.