Reputation: 559
in my app I try to display a markdown string generated by ChatGPT by converting it to html with Markdig. The markdown contains Latex formulas enclosed in \[
and \]
and when I convert the string as follows, some backslashes are consumed, which breaks the LaTeX formulas:
string original = "A **formula** from chatGPT:\\[\\frac{7 \\, \\text{J} - 4 \\text{ N}}{3 \\text{ m}^2}\\]";
var pipeline = new MarkdownPipelineBuilder().Build();
html = Markdown.ToHtml(original, pipeline0);
// html is now "<p>A <strong>formula</strong> from chatGPT:[\frac{7 , \text{J} - 4 \text{ N}}{3 \text{ m}^2}]</p>" (without a few backslashes)
In the example above, the backslashes in front of [
and ]
are missing, and also in front of the ,
. I found a workaround by doubling the backslashes manually, but I still wonder what I do wrong with Markdig, because there might be other escaped characters that are consumed, which I did not yet experience in my formulas.
Upvotes: 0
Views: 90