asciidoctor / asciimath

Asciimath parser
MIT License
24 stars 16 forks source link

Consider supporting an alternative to AsciiMath #32

Open davidfarmer opened 4 years ago

davidfarmer commented 4 years ago

In a previous issue was written:

I'm currently studying markup languages that can serve as a viable alternative to LaTeX in the academic document preparation space.

Let me describe some thoughts about this.

First, there is no existing viable alternative. But I think it is possible to invent one, which I started doing a couple years ago. I had a student working on a project, which started out as a way to convert AsciiMath to LaTeX. (There exists such a converter, but it does not output LaTeX in a form a human would write.) After working for a while, we decided to rethink the AsciiMath syntax and create a new (but similar-looking) math markup language. We got pretty far, but then the student graduated and I have not actively worked on that project (but I continue to think about it and intend to return to it).

I named the project "Space Math" and started sketching a retro 1950's logo. The name comes from the critical role that the space character plays. As mentioned elsewhere, you can disambiguate function application and implied multiplication: f(x) means function application because there is no space between the f and the (x).

We also found the need to introduce some Python-like syntax for expressions that naturally take up multiple lines. The markup is intended to be human readable and human writable, for example:

abs(x) = cases:
    x if x >= 0
   -x if x < 0

Note also the abs keyword. This is preferable to |.| because out of context the meaning of |A| is ambiguous. The use of multiple lines was considered a deal-breaker for AsciiMath, but for me it is a deal-breaker that there is no good way to write the above construction, or multiline equations or derivations, in AsciiMath.

I don't claim that we totally figured out everything, but we definitely were on the right track and were able to handle a lot of things that didn't work well in AsciiMath.

I can dig up my old material if you think this is worth considering.

I should also mention that my use case for this was the PreTeXt authoring system, a project in which I am actively involved: https://pretextbook.org .

pepijnve commented 4 years ago

I can dig up my old material if you think this is worth considering.

Absolutely. I can't make any promises in terms of timelines, this is all volunteer work after all, but I'm definitely interested to have a look at what you were working on.

I'm looking at this the same way you build compilers for instance. We can have distinct AsciiMath and SpaceMath frontends that generate a common intermediate representation (i.e. the AST). The backends work off of the AST to generate output. In other words, supporting AsciiMath as is and supporting additional syntaxes are not mutually exclusive options.

GarkGarcia commented 4 years ago

First, there is no existing viable alternative.

I absolutely agree. As of now, my work in here and in other asciidoctor repos is geared towards improving facilities for mathematical and academic publishing in the Asciidoctor ecosystem. I'm happy to see we share common goals.

But I think it is possible to invent one, which I started doing a couple years ago. I had a student working on a project, which started out as a way to convert AsciiMath to LaTeX. (There exists such a converter, but it does not output LaTeX in a form a human would write.) After working for a while, we decided to rethink the AsciiMath syntax and create a new (but similar-looking) math markup language. We got pretty far, but then the student graduated and I have not actively worked on that project (but I continue to think about it and intend to return to it).

This sounds very interesting to me. I'd love to have a look at the material you mentioned.

I'm looking at this the same way you build compilers for instance. We can have distinct AsciiMath and SpaceMath frontends that generate a common intermediate representation (i.e. the AST).

Absolutely. The current AST is geared towards parsing AsciiMath, so we'd probably have to addapt it a bit, but the recent AST redesign might be a good starting place.

We should probably formalize the SpaceMath grammar before we start working on this thought. @davidfarmer Could you create a repository for further discussions? The materials you've mentioned could be placed in there.

pepijnve commented 4 years ago

http://www.unicode.org/notes/tn28/UTN28-PlainTextMath-v3.pdf might be interesting to have a look at as well. Expecting people to enter unicode characters manually isn't very realistic though. So you would either have tons of \... autocorrect macros (but then you might as well just use LaTeX math mode) or have to lean heavily on editor support.

opoudjis commented 4 years ago

Btw I don't have an opinion about this (well, actually I do, which is AsciiMath is fine though not centrally defined); but I'll note that http://www.unicode.org/notes/tn28/UTN28-PlainTextMath-v3.pdf is as close as we have to a window into what Microsoft Word thinks it's doing with its maths expressions (including what Microsoft consider to be n-ary operations, which we were discussing in a different thread.)

GarkGarcia commented 4 years ago

The following may also be relevant to the discussion:

http://xml.coverpages.org/coombs.html

I've transpiled the web-page to Asciidoc and rendered it to PDF. If anyone wants a copy of it I can send it via email. I'm not sure about how the article is licensed, so I wont distribute it in here.

GarkGarcia commented 3 years ago

@davidfarmer Any updates?

davidfarmer commented 3 years ago

My update is I wish "the current situation" wasn't causing me an enormous amount of extra work so I could get back to some projects that I would like to make progress on.

I have not forgotten about this.

GarkGarcia commented 3 years ago

My update is I wish "the current situation" wasn't causing me an enormous amount of extra work so I could get back to some projects that I would like to make progress on.

I understand, those are difficult times indeed, sorry for the annoyance. Hoping to see the material you mentioned.

davidfarmer commented 3 years ago

Not annoying. Glad to be reminded there is interest.

On Thu, 27 Aug 2020, Gark Garcia wrote:

  My update is I wish "the current situation" wasn't causing me an enormous amount of extra work so I could get back to
  some projects that I would like to make progress on.

I understand, those are difficult times indeed, sorry for the annoyance. Hoping to see the material you mentioned.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, orunsubscribe.[AABTULAWNF4U2QTINDLH723SC3OCJA5CNFSM4MZ2PRZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFCU7DOY.gif ]

sebi5361 commented 3 years ago

Dear David, thank you for your useful comment on my AsciiMath issue you mentioned just above. I would love to see Space Math in its current state or to discuss in this thread what could be the expectations for this AsciiMath-improved langage. Do not hesitate to publish your open-source code as it is in its current state so we could dive in. In am sure you have already consider it, but it might me a good idea to involve your former student in this project, as he might be of great help to us. A few elements below to give us some matter to think about:

Do you consider to have alpha, \alpha and α be rendered the same way in Space Math? I think this would be a neat feature.