asciimath / asciimathml

A new home for asciimathml
http://asciimath.org/
MIT License
957 stars 183 forks source link

dtheta renders as dth\eta #105

Closed jolyonb closed 4 years ago

jolyonb commented 5 years ago

Pretty much what it says in the title. Entering dtheta, which I expected would give me d\theta in LaTeX, instead gives dth\eta. Not sure why \eta has precedence over \theta in this situation!

I'm aware that I can instead write d{::}theta, but that shouldn't be necessary, right???

davidfarmer commented 5 years ago

I usually write it as d theta

But I agree it is not expected behavior.

Weirdly, dvartheta behaves as expected.

On Sat, 18 May 2019, Jolyon Bloomfield wrote:

Pretty much what it says in the title. Entering dtheta, which I expected would give me d\theta in LaTeX, instead gives dth\eta. Not sure why \eta has precedence over \theta in this situation!

I'm aware that I can instead write d{::}theta, but that shouldn't be necessary, right???

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.[AABTULG636WHV5EC37VNRGDPWDIZHA5CNFSM4HN3TXM2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GUSBLOQ.gif]

saivan commented 5 years ago

That could just be operator precedence right? \eta probably appears before \theta. So you could probably fix this by changing the order of the operators in the source; but could that have any unintended consequences?

drlippman commented 4 years ago

AsciiMath doesn't define or consider operator precedence. It parses a string from left to right, looking for the largest symbol.

For dtheta, it starts at the left and finds the symbol dt. From there it parses the remaining heta, doesn't find a symbol, so moves on and finds the symbol eta. So your expression is actually parsing (correctly, based on the syntax) as dt h eta.

As David Farmer noted, the correct way to prevent matching symbols you don't want is to add spacing, so d theta works because it breaks apart the dt symbol.

jolyonb commented 4 years ago

Ah, didn't realize there was a dt symbol. That explains the behavior.