
Show HN: Mathup – A simple MathML authoring tool - runarberg
https://runarberg.github.io/mathup/
======
jake-low
This is pretty neat. A week or so ago when "MathJax turns 3.0" was on the
frontpage [0], I followed a link to this very thoughtful comment [1] from 2019
by svat about the landscape of math typesetting on the web. Since then I've
been thinking a little bit about MathML and how compilers from other more
input-friendly formats to MathML might encourage wider adoption. So I'm
excited to see this library.

I've heard of AsciiMath before but hadn't ever had a chance to play with it,
so I appreciated the live demo on the project website. One thing I noticed is
that AsciiMath uses whitespace around operators to determine binding order.

For example (AsciiMath on left, TeX on right)

    
    
        f(x) = x+1 / 2    ≡    f(x) = \frac{x + 1}{2}
        f(x) = x + 1/2    ≡    f(x) = x + \frac{1}{2}
    

When there's equal spacing around neighboring operators, normal order of
operations seems to apply.

This seems fairly intuitive, but might not scale to large, complex equations
as well as TeX's bracket syntax does. Nonetheless, I think I like it for
simple equations.

Question for the author: you mention on the page that Mathup supports an input
language inspired by AsciiMath [2]. What are the differences? Does Mathup
accept a subset of AsciiMath, or are there cases where the syntax diverges?
And if the latter is the case, what motivated devaiting from AsciiMath's
syntax?

[0]:
[https://news.ycombinator.com/item?id=22582343](https://news.ycombinator.com/item?id=22582343)

[1]:
[https://news.ycombinator.com/item?id=19347737](https://news.ycombinator.com/item?id=19347737)

[2]: There's a typo in this phrase on your page, BTW: "insipired" has an extra
"i"

~~~
runarberg
Thanks for the comment. This project was previously called _Ascii2MathML_ and
I tried to stay as true to the original AsciiMath language as possible. But
I’ve since then moved away from it (which is why I renamed it to _mathup_ ) as
I found it could be improved upon in some minor ways (personal preference
really).

There are some trivial differences: e.g. `bf` for boldface instead of
AsciiMath’s `bb`; or the `.^` infix for overscripts instead of the `over`
prefix. The matrix syntax is also quite different: AsciiMath uses nested
brackets, while mathup uses row separators (`;` or `\n`). Most significant is
the difference in grammar (you’ve noted the significant white space which is
not a feature of AsciiMath).

You can see my attempt of writing down the grammar here[1]. However I’m very
much a novice when it comes to compilers and lexical analysis, so this grammar
is probably not accurate—in fact when I originally wrote Ascii2MathML I wasn’t
even aware that I was writing a compiler. But in words, a set of tokens and
operators with no internal white space tends to be grouped together. There are
a few infixes (`/`, `^`, `_`, etc.) which generally take precedence but
operate on a group of non spaced tokens if they are able to.

I originally wrote this because I wanted people that didn’t necessarily know
TeX to be able to drop in a simple expression in comment threads and forums. I
also liked to provide as much expressive power as possible, but I found
AsciiMath lacking a little in expressiveness. The white space significance I
found made writing a little easier, but in longer expressions it is a bit hard
to use, but then again, this tool was always intended for smaller expressions
anyway.

[1]:
[https://github.com/runarberg/mathup/blob/master/GRAMMAR](https://github.com/runarberg/mathup/blob/master/GRAMMAR)

------
mirekrusin
Loading library fails on the page and the whole project looks like april's
fools day joke, ie. the whole library being an identity function.

~~~
runarberg
The library translates into MathML which might not be supported by your
browser. There is a ‘MathJax polyfill’ option you can opt into below the
output.

~~~
mirekrusin
That wasn't the case - now it works fine, before there were errors while
trying to load resources.

