Asciimath support?

Asciimath (http://asciimath.org/) offers a simpler notation for the most often-used mathematical symbols. I think it would be awesome if Obsidian could add some support for this!

MathJax already supports asciimath with a plugin (AsciiMath Support — MathJax 3.1 documentation) so in that sense it is somewhat relevant to this: MathJax extensions.

However, I’ve found that feature to be a little lacking. While asciimath is great for typing short math, it lacks the greater set of latex primitives, such as alignment. Therefore, I would advocate for backticks used inside of dollar signs to be preprocessed into latex first.

That is, we might write something like this markdown file:

$$
\begin{aligned}
`sum_(i=1)^n i^3`
    &= `((n(n+1))/2)^2` \\
    &= `(n(n+1))^2/2^2`
\end{aligned}
$$

I have a simple pandoc filter using the asciimath2tex javascript library to do some preprocessing. Here is its entirety. The details of pandoc don’t matter, but I just wanted to show it’s simplicity. It’s just detecting any text surrounded in backticks inside of math equations and running a converter to translate it to latex.

#!/usr/bin/env node

var pandoc = require('pandoc-filter');
var Formula = pandoc.Formula

const AsciiMathParser = require('./asciimath2tex.js')
const parser = new AsciiMathParser()


function action({t: type, c: value},format,meta) {
    if (type === 'Math' && value.length == 2) {
        switch(value[0]['t']) {
            case 'DisplayMath':
            case 'InlineMath':
                latex = value[1].replace(/`(.*?)`/g, function(match, capture) {
                    return parser.parse(capture)
                })
                return Formula(value[0], latex)
        }
    }
}

pandoc.stdio(action);

I’m hoping something like this could be built into Obsidian. Perhaps would be more appropriate when the plugins system comes out, but I just wanted to raise this feature idea here.

EDIT: one does not need pandoc to detect math blocks, Zettlr has these simple regular expressions: Zettlr/zettlr-plugin-render-math.js at 2f2d96f975510501cf9bdc71c6e80234e919f83c · Zettlr/Zettlr · GitHub

5 Likes

Yes, please

ASCIIMath looks so much simpler than Mathjax!

Would dearly like this to be an option in Obsidian.

1 Like

I would love this too! +1