zhaoshenzhai / obsidian-mathlinks

An Obsidian.md plugin to render MathJax in your links.
MIT License
59 stars 4 forks source link

Pitfall regarding `mathLink-blocks` #39

Open RyotaUshio opened 1 year ago

RyotaUshio commented 1 year ago

Hi, I noticed a pitfall regarding mathLink-blocks. It's not a bug of MathLinks, but I will post it because it would be helpful for some users.

The following mathLink-blocks doesn't work. As you can see in the console, 6e0363 is not treated as a string "6e0363", but becomes Infinity. Probably this is because YAML interprets something like 6e0363 as a hexadecimal number (not a string!). Moreover, 4e5530 is not even recognized. (I'm not sure why about this.)

image

If you wrap each block ID with quotes, it is now recognized as a string, and things work.

image
DoctorDalek1963 commented 1 year ago

Interestingly, this isn't a problem with hexadecimal numbers, but only numbers of the form [0-9]+e[0-9]+, since these get interpreted as exponential notation. 9890d5 is probably getting interpreted as a string, but 4e5530 gets interpreted as 4 * 10^5530, which is too big to fit in a floating point number, and becomes infinity. Then 6e0363 becomes 6 * 10^363, which is also too big, and overwrites the first infinity.

This is a very niche behaviour which is entirely because of YAML, and can only really be fixed by enclosing the IDs in quotes.

RyotaUshio commented 1 year ago

Ahh that's why... Thanks a lot, You solved the mystery!! What a coincidence to hit that form twice in a row