tag:support.markedapp.com,2011-09-11:/discussions/problems/164211-katex-not-rendering-correctly-in-html-exportMarked: Discussion 2021-09-25T18:33:10Ztag:support.markedapp.com,2011-09-11:Comment/493819762021-09-22T16:11:37Z2021-09-22T16:19:50ZKatex not rendering correctly in html export<div><p>With the new update <code>$</code> is broken as well...<br>
It renders to <code>\(</code> and <code>\)</code> both in the app and in html exports.</p></div>einar.risholmtag:support.markedapp.com,2011-09-11:Comment/493819762021-09-23T01:31:51Z2021-09-23T01:31:51ZKatex not rendering correctly in html export<div><p>I didn't make any changes to MathJax/Katex handling at all in the last update, and I stopped it from doing the <code>\\[</code> replacements a couple of versions ago. Are you really on the latest?</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/493819762021-09-23T08:14:11Z2021-09-23T08:14:11ZKatex not rendering correctly in html export<div><p>I'm using version 2.6.10.</p></div>einar.risholmtag:support.markedapp.com,2011-09-11:Comment/493819762021-09-23T10:29:32Z2021-09-23T10:29:32ZKatex not rendering correctly in html export<div><p>I have completely removed Marked 2 and reinstalled it. The issue is still present.</p></div>einar.risholmtag:support.markedapp.com,2011-09-11:Comment/493819762021-09-23T19:06:30Z2021-09-23T19:06:30ZKatex not rendering correctly in html export<div><p>It looks like it's not the syntax replacement that's broken, it's the<br>
entire Katex install. The script isn't loading properly. Possible to use<br>
MathJax until I have a chance to figure out what's going on?</p>
<p>Also, you're correct, when using the MultiMarkdown processor Marked is<br>
still replacing $ with ( and $$ with [, which is for compatibility<br>
with MMD math processing. I'll look back into just disabling that, but<br>
in the mean time, if using the Discount (GFM) processor is an option, it<br>
shouldn't alter your markup when using that.</p>
<p>-Brett</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/493819762021-09-24T06:54:38Z2021-09-24T06:54:38ZKatex not rendering correctly in html export<div><p>So both Katex and MultiMarkdown are causing problems. Switched to MathJax for now, although this introduces a new set of problems like lack of text mode macros that breaks rendering, but that issue is beyond Marked 2. Will I get any feedback on when Katex renders properly?</p></div>einar.risholmtag:support.markedapp.com,2011-09-11:Comment/493819762021-09-24T17:38:37Z2021-09-24T17:38:37ZKatex not rendering correctly in html export<div><p>I pushed an update yesterday that at least gets Katex running again. If<br>
you're on the direct-download version, you'll have to update by<br>
downloading as I managed to break the auto-update on the last version.</p>
<p>The new version does not address the original issue, though. I double<br>
checked, and Marked is not making any alterations to <code>$$</code> syntax<br>
internally, so it has to be something happening in the Markdown<br>
processors. Can you share a snippet of text containing an equation and<br>
the syntax that demonstrates the issue?</p>
<p>Thanks,<br>
Brett</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/493819762021-09-25T06:29:58Z2021-09-25T09:48:44ZKatex not rendering correctly in html export<div><p>The following snippets renders properly with Katex in Marked 2 and breaks in html export:<br>
Inline<br></p>
<pre>
<code>$(2*3 = 6)$</code>
</pre>
Display mode<br>
<pre>
<code>$$\rightarrow ONE - TWO - THREE \rightarrow FOUR - FIVE - SIX$$</code>
</pre>
Display mode with <code>\\</code> line break<br>
<pre>
<code>$$\rightarrow ONE - TWO - THREE \\ \rightarrow FOUR - FIVE - SIX$$</code>
</pre>
There still seems to be a parsing problem in Marked 2. If I make a syntax error that breaks rendering, fix the error, save the document and refresh Marked 2, the equation don't update, but appears as if no changes where made. I have to edit somewhere else in the document for Marked 2 to refresh properly. The html export issues are the same as before, <code>$</code> translates to <code>\(</code> and <code>$$</code> translates to <code>\[</code>, resulting in syntax error.
<p>The last but not least snippet worked before, but are not rendered at all anymore. Every snippet here works as expected on stackedit.io, which also use katex.<br></p>
<pre>
<code>$$
\rightarrow ONE - TWO - THREE \\
\rightarrow FOUR - FIVE - SIX
$$</code>
</pre></div>einar.risholmtag:support.markedapp.com,2011-09-11:Comment/493819762021-09-25T18:33:07Z2021-09-25T18:33:07ZKatex not rendering correctly in html export<div><p>Just tested running it directly through MultiMarkdown and that's definitely where the syntax conversion is happening. I can't do anything about that. However, I can adjust the exported HTML to handle them.</p>
<p>If you want to edit the exports yourself, here's what needs to be included (replacing the Katex script reference that Marked includes now). I'll be updating Marked to do this itself soon.</p>
<pre>
<code><script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.js" integrity="sha384-GxNFqL3r9uRJQhR+47eDxuPoNE7yLftQM8LcxzgS4HT73tp970WS/wV5p8UzCOmb" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/contrib/auto-render.min.js" integrity="sha384-vZTG03m+2yp6N6BNi5iM4rW4oIwk5DfcNdFfxkk9ZWpDriOkXX8voJBFrAO7MpVl" crossorigin="anonymous"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body, {
// customised options
// • auto-render specific keys, e.g.:
delimiters: [
{left: '$$', right: '$$', display: true},
{left: '$', right: '$', display: false},
{left: '\\(', right: '\\)', display: false},
{left: '\\[', right: '\\]', display: true}
],
// • rendering keys, e.g.:
throwOnError : false
});
});
</script></code>
</pre>
<p>As far as the bug where you can't make edits inside of equations goes, I'm going to have to look further into that. Until I solve it, you can get around it by just placing the cursor outside of the <code>$$</code> and hitting space->⌘S to get it to update the render.</p></div>Brett