Closed williamstein closed 2 years ago
@William, thanks a lot for your kind words. I continue maintaining markdown-it-texmath
at current, after a while of doing other things.
I consider integrating MathJax worth an attempt in the near future. I will try out your interesting script then also, which - I must confess - I do not understand completely (perhaps I need to learn a little more about MathJax first).
Your solution for \begin{...}...\end{...}
seems to be of general interest (Yupiter + cocalc), so I will support it starting with version 0.9.8 .
Thanks for your support.
Your regular expression (slightly modified by me)
/(\\(?:begin)\{([a-z]+)\}[\s\S]+?\\(?:end)\{[a-z]+\})/gmy
won't work with nested \begin{...}...\end{...}
content like
\begin{equation}
\begin{pmatrix}
A & B \\ B & C
\end{pmatrix}
\end{equation}
Using Regex backreference here helps ...
/(\\(?:begin)\{([a-z]+)\}[\s\S]+?\\(?:end)\{\2\})/gmy
thanks
Your workaround above can now be replaced by using:
delimiters: ['dollars', 'beg_end']
with Version 1.0
Thanks. I ended up getting a lot of feedback from my users about exactly what regexps, and in what order, etc., I was using.
They are a little different than when I wrote the comments above. I also added support for using \begin{math}...\end{math}
for inline math, like in latex. Anyway, the exact rules I'm using are here, and they seem to have resulted in the least amount of complaints from people used to what's in Jupyter notebooks:
https://github.com/sagemathinc/cocalc/blob/master/src/packages/frontend/markdown/math-plugin.ts#L129
It does differ in some other ways from what you do, e.g., here's one:
{
// We modify this from what's included in markdown-it-texmath to allow for
// multiple line inline formulas, e.g., "$2+\n3$" should work, but doesn't in upstream.
name: "math_inline",
rex: /\$((?:[^\$\s\\])|(?:[\S\s]*?[^\\]))\$/gmy,
tag: "$",
outerSpace: false,
pre,
post,
},
That said, of course they way you did it by adding beg_end is nice since you can preserve backward compatibility for users of your plugin. If nothing else, the point of this comment here is just that it could be useful for other users wanting more options...
@williamstein @goessner Hi! You are very cool and your dev! Thanks. Could you advise me how can i use markdown-it-texmath with type script? where i can find types for it?
I'm not aware of a discussion board, but just wanted to say thanks for this plugin. I just integrated it extensively into https://cocalc.com in this commit.
Regarding "Why doesn't markdown-it-texmath work with other engines ?" from the README, I needed to make this also work with mathjax (though we mainly use katex), and found it very easy to do so by using this option when creating the plugin:
I also needed to parse math environments that is determined by \begin/\end environments, but no dollar signs at all, e.g.,
None of the delimiters you have support that, so I just extended the built in dollars one via a new delimiter called "cocalc" that does right after loading as follows. This didn't require changing the code of this extension at all. The regular expression below took me a while to come up with:
In any case, many thanks for writing (and maintaining!) this plugin.