Katex not rendering correctly in html export
I use a little LaTex, and it usually renders nicely in the app. I have noticed however, that the $$
are sometimes converted to \\[
and \\]
, and failing to render properly. This happens every time I convert to html, and I have to manually remove them. The display equation should also automatically center align, but are aligned to the left. I can correct this by adding display: block; text-align: center;
to the .katex class.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by einar.risholm on 22 Sep, 2021 04:11 PM
With the new update
$
is broken as well...It renders to
\(
and\)
both in the app and in html exports.Support Staff 2 Posted by Brett on 23 Sep, 2021 01:31 AM
I didn't make any changes to MathJax/Katex handling at all in the last update, and I stopped it from doing the
\\[
replacements a couple of versions ago. Are you really on the latest?3 Posted by einar.risholm on 23 Sep, 2021 08:14 AM
I'm using version 2.6.10.
4 Posted by einar.risholm on 23 Sep, 2021 10:29 AM
I have completely removed Marked 2 and reinstalled it. The issue is still present.
Support Staff 5 Posted by Brett on 23 Sep, 2021 07:06 PM
It looks like it's not the syntax replacement that's broken, it's the
entire Katex install. The script isn't loading properly. Possible to use
MathJax until I have a chance to figure out what's going on?
Also, you're correct, when using the MultiMarkdown processor Marked is
still replacing $ with \( and $$ with \[, which is for compatibility
with MMD math processing. I'll look back into just disabling that, but
in the mean time, if using the Discount (GFM) processor is an option, it
shouldn't alter your markup when using that.
-Brett
6 Posted by einar.risholm on 24 Sep, 2021 06:54 AM
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?
Support Staff 7 Posted by Brett on 24 Sep, 2021 05:38 PM
I pushed an update yesterday that at least gets Katex running again. If
you're on the direct-download version, you'll have to update by
downloading as I managed to break the auto-update on the last version.
The new version does not address the original issue, though. I double
checked, and Marked is not making any alterations to `$$` syntax
internally, so it has to be something happening in the Markdown
processors. Can you share a snippet of text containing an equation and
the syntax that demonstrates the issue?
Thanks,
Brett
8 Posted by einar.risholm on 25 Sep, 2021 06:29 AM
The following snippets renders properly with Katex in Marked 2 and breaks in html export:
Display modeInline
Display mode with
\\
line breakThere 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,
$
translates to\(
and$$
translates to\[
, resulting in syntax error.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.
Support Staff 9 Posted by Brett on 25 Sep, 2021 06:33 PM
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.
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.
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
$$
and hitting space->⌘S to get it to update the render.