Alright I managed to figure it out by reading the MMark docs, apparently it has to be in a code span. It would be nice to explain this in neuron.srid.ca maybe? It's not really obvious for someone that has never used MMark.
I'm writting a zettel to explain how to use mathjax but I think I found a bug in MMark when typing ^ in $$ ... $$ blocks
Also it seems that MMark doesn't handle escapes very well
(fwiw, mmark is parsing using megaparsec, so if there is a bug in the parser it can be fixed easily in mmark; but I don't know enough about mathjax syntax to make a call)
Yeah escaping ^ works but latex already has enough \ lol, I think mmark has a special syntax with ^ for typing superscripts but it's not handled by the mathjax parser, which would need to have "higher precedence" somehow
Oh they may operate on Pandoc's parsed structure rather than close to Markdown ... don't know. Will need investigation. I probably won't get to doing anything substantial in neuron for a while.
---
title: Writing LaTeX in your zettels
---
You can type LaTeX code in zettels in three ways:
- Inline: by surrounding your code with \`\$ ... \$\`
- Block: LaTeX can be displayed in a centered block when surrounded with $$
- Multiple lines at once: \`\`\`mathjax ... \`\`\`
Warning: the `mathjax` code block will treat each line as a separate LaTeX
expression. Thus you can't write `\begin{...}` and `\end{...}` on separate
lines.
This last point about each line being treated as a separate expression feels quite unnatural to me
Add documentation about mathjax support from zettel markdown.
This is needed because MMark uses unconventional notation for LaTeX input.
Some features also have unexpected bugs as $$ ... $$ blocks ...
I was trying to use MathJax in neuron and it appears that inline LaTeX isn't working properly.
I can use
$$
just fine but single$
for inline formulas isn't rendered, which is weird given this line:https://github.com/srid/rib/blob/master/src/Rib/Parser/MMark.hs#L119
Alright I managed to figure it out by reading the MMark docs, apparently it has to be in a code span. It would be nice to explain this in neuron.srid.ca maybe? It's not really obvious for someone that has never used MMark.
I'm not familiar with mathjax. If you could give me an example I'll add it
I'm writting a zettel to explain how to use mathjax but I think I found a bug in MMark when typing
^
in$$ ... $$
blocksAlso it seems that MMark doesn't handle escapes very well
Does escaping it like
\^
work?Looks like maybe it is worth switching to Pandoc after all ...
(fwiw, mmark is parsing using megaparsec, so if there is a bug in the parser it can be fixed easily in mmark; but I don't know enough about mathjax syntax to make a call)
Sridhar Ratnakumar said:
Yeah escaping ^ works but latex already has enough \ lol, I think mmark has a special syntax with ^ for typing superscripts but it's not handled by the mathjax parser, which would need to have "higher precedence" somehow
The extension is here: https://github.com/mmark-md/mmark-ext/blob/master/Text/MMark/Extension/MathJax.hs
can pandoc manage custom markdown extensions?
Looks like it; http://hackage.haskell.org/package/pandoc-2.9/docs/Text-Pandoc-Extensions.html
Oh they may operate on Pandoc's parsed structure rather than close to Markdown ... don't know. Will need investigation. I probably won't get to doing anything substantial in neuron for a while.
But... I wonder if one can somehow make mmark behave properly.
Maybe to support "raw" math thingy, we could do it as:
(Assuming those backticks prevent use of markdown syntax inside)
Perhaps you can fork mmark-ext and play with it
Wait, the extension already supports fenced code blocks?
See line 75,76
This works for me: image.png
Yeah this works, the issue is for ... blocks
Blocks?
sorry, \$\$ ... \$\$
Don't
$$..$$
and the fenced code version render the same?At least in neuron,
$$...$$
renders as a block (not inline).yeah
$ ... $
is inline and$$ ... $$
renders as a centered block, a fenced code with 1 line behaves as$$ ... $$
thoughTo me
$...$
does nothinganyway here is the zettel i started writing:
This last point about each line being treated as a separate expression feels quite unnatural to me
Aha, $...$ need to be inside ticks
Like image.png
"^" works in the above
@felko Where did you gather that "$$" is supported? I don't see it reading the extension source.
Sridhar Ratnakumar said:
It's a common notation in discord LaTeX bots or in math forums so i tried it and it worked (at least partially)
Maybe the bug is actually the fact that
$$ ... $$
works at allThis mmark extension does not follow any hardcoded convention like that; it allows the user to customize the fencers for inline text.
The extension takes a character as parameter, and rib passes
$
(cf.Ext.mathJax (Just '$')
).Ah
You are right, so that's point 2 in your zettel.
@felko Maybe it is the JavaScript include that is doing it. Not mmark-ext.
Yeah that's possible
You can simply note this limitation in your point 2, I guess. And then recommend people opt for point 3.
good idea, do you want me to write the thing and do a PR on the guide zettelkasten?
As a PR, sure. You can put it under
Guide -> Zettel Markdown -> Math support
https://github.com/srid/neuron/pull/63