# MathJax - Neuron

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

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 Haskell static site generator based on Shake. Contribute to srid/rib development by creating an account on GitHub. 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 $$ ... $$ blocks Also 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: Does escaping it like \^ work? 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 Commonly useful extensions for the MMark markdown processor - mmark-md/mmark-ext can pandoc manage custom markdown extensions? 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: Some text and $$math formulat$$  (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? Yeah this works, the issue is for $...$ 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 $$ ... $$ though To me ... does nothing anyway here is the zettel i started writing: --- 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

Aha, $...$ need to be inside ticks

@felko Where did you gather that "$$" is supported? I don't see it reading the extension source. Sridhar Ratnakumar said: felko Where did you gather that "$$" is supported? I don't see it reading the extension source.

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 all

This 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 '$')).

Maybe the bug is actually the fact that $...$ works at all

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

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 ...