_           _                 
 | |_ ___  __| |____  ___ _   _ 
 | __/ _ \/ _` |_  / / _ \ | | |
 | ||  __/ (_| |/ / |  __/ |_| |
  \__\___|\__,_/___(_)___|\__,_|

More pandoc and MathML for Jotz CMS, including equation font size

Example markdown:

This is the first paragraph.

It has been said that $y = mx+c$, which is often true.

$$Z = R + jX$$

This is the last paragraph.

To convert an equation to MathML within vim, visually select the equation paragraph by typing "vip" then type "!" and run the following command to convert the lines to MathML:

:.!pandoc --mathml

Note that the following may actually be preferable because it strips out the unnecessary <p> and </p> tags, which may cause problems later on if reverting the MathML equations back to TeX so that the markdown can be processed by e.g. pandoc.

:.!pandoc --mathml | sed -e 's/<\/*p>//'

Anyway, the result (without stripping the <p> tags) is...

This is the first paragraph.

<p>It has been said that
<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>y</mi><mo>=</mo><mi>m</mi><mi>x</mi><mo>+</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">y = mx+c</annotation></semantics></math>,
which is often true.</p>

<p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Z</mi><mo>=</mo><mi>R</mi><mo>+</mo><mi>j</mi><mi>X</mi></mrow><annotation encoding="application/x-tex">Z = R + jX</annotation></semantics></math></p>

This is the last paragraph.

...which renders as...

This is the first paragraph.

It has been said that y=mx+cy = mx+c, which is often true.

Z=R+jXZ = R + jX

This is the last paragraph.

Setting font size for equations

To increase the font size for block level equations, but not for inline equations, I added the following snippet to the beginning of the article. It could also be added to the custom CSS for a Jotz CMS blog.

<style>
math[display="block"] {font-size:2em;}
</style>

Stripping MathML elements back to just the annotation content

I've been experimenting with vim substitution commands to strip each MathMl elements back to just the content of the annotation element within it, which pandoc normally populates with the original TeX expression that it converted into MathML. Basically, I'd like to be able to download the markdown for one or more Jotz CMS articles and automatically pre-process it so that pandoc can render it as a PDF or whatever. Ideally, I would like to be able to seamlessly convert all equations (block and inline) in an article back and forth between TeX and MathML.

This expression works for a block math element, wrapping the annotation contents with $$ marks:

:%s/^.*<math.*block.*<annotation.*>\(.*\)<\/annotation.*$/\$\$\1\$\$/

This expression works for an inline math element, wrapping the annotation contents with $ marks:

:%s/^.*<math.*inline.*<annotation.*>\(.*\)<\/annotation.*$/\$\1\$/