Open azerupi opened 7 years ago
Couldn't this be implemented entirely in JavaScript (see the MathJax Docs)?
Ah thanks for reminding me, I forgot the most important part of this issue!
Currently, math expressions will collide with markdown syntax. If you write a*b*c=d
the markdown parser will emphasise b
, which is not what we want.
So to make mathjax fully usable, we need to preprocess the equations and replace it with something that will be skipped by the markdown parser. The solution in my first post will therefore not work.
What I propose is to wrap the math equations with html tags. For inline <span class="inline-math">...</span>
and for blocks <div class="math"></div>
. The markdown parser will recognise this as raw HTML and will leave it as is.
I would like to look into this. Will start a branch and send in a WIP pull request
I'm wondering if it would be better to switch to using code-fences for embedded markup languages, as suggested in this thread on the CommonMark forums, eg:
```{latex}
\begin{tikzpicture}
\node[inner sep=0pt] (russell) at (0,0)
{\includegraphics[width=.25\textwidth]{bertrand_russell.jpg}};
\node[inner sep=0pt] (whitehead) at (5,-6)
{\includegraphics[width=.25\textwidth]{alfred_north_whitehead.jpg}};
\draw[<->,thick] (russell.south east) -- (whitehead.north west)
node[midway,fill=white] {Principia Mathematica};
\end{tikzpicture}
This would also have the advantage of making the [github previews](https://github.com/brendanzab/pikelet/blob/23e9cb1a5b9b49810573f777f86b63b27adcdf83/book/src/appendix/theory.md#raw-terms) look much nicer. We might have to wait for this to go through the pipeline of standardization though. :/
I'll naively plug tectonic. It is a full LaTeX engine partially written in rust that could potentially integrate with mdBook for advanced formatting needs.
Does anyone happen to be working on this right now? If not, the Rust ML WG is interested in picking this task up.
@vadixidav I doubt anyone is looking at it. Feel free to take a look, though I'm not up to speed with what the problems are (I think maybe mathjax needs to be a preprocessor?).
I am not @vadixidav.
I'm not working on this, but I'll leave two pointers here which are hopefully useful to people who are:
$ ... $
/ $$ ... $$
syntax is currently the most widespread.Hey, I created recently a small plugin for scientific mdbook
. This adds support for latex
, gnuplot
, and bibtex
rendering. Equations are rendered to SVG without KaTeX or MathJax, but I'm planing to support them later on. I also added support for referencing/citations across the book. A sample can be found here and the github repository here.
This is exactly a great feature to be considered.
Github seems to have no problem of using MathJax over Markdown using the obvious Latex syntax $...$
and $$...$$
. What is the reason this is not the case for mdBook and can't the same approach as for Github be used?
I think this is overall blocked on https://github.com/raphlinus/pulldown-cmark/pull/622.
mdbook-katex is now quite feature-complete, capable of producing completely static outputs. It is also capable of rendering inside <detail></detail>
blocks with no issue (@your-diary 's #1926), and uses the $...$
and $$...$$
delimiter by default and can add custom delimiters.
See https://github.com/SichangHe/mdbook_katex_static_css/
Any reason why the CDN-delivered MathJax must have the exclusive privilege of being the "default"?
Since I got lost in this and a few other open issues: https://github.com/lzanini/mdbook-katex works well.
@ehuss Would you consdier, also from a maintainability viewpoint, to drop MathJax and recommend users to use an extension such as mdbook-katex
?
Currently, Mathjax is a little akward to use because we only support the
\( ... \)
and\[ ... \]
method to indicate inline and block equations respectively. On top of that, backslashes need to be escaped so that the markdown parser doesn't remove them. Thus, equations need to be written like:So when mathjax support is enabled in the configuration, it would be great to add a preprocessor that rewrites the
\[ ... \]
forms to\\[ ... \\]
and add support for the$$ ... $$
math delimiters.