Esoteric Update #304 - A MathML Of My Own


You'll have to excuse me, but I got distracted by a few technical issues this week. One of them is a bit of a personal pet peeve, so I'll discuss it in length a bit later on. Unfortunately, this was also my first week at work after my very much-needed health break, and oh boy, was it rough.

Firstly, a minor thing: I've looked at the syntax related to responders and introduced a new extension to reduce boiler plating in building responses. Actually, it removes all boiler plating in the main body of a responder's entry, thus reducing the size of a single entry by 25% to 50% (the latter in the case of dialogue options). It also codifies the ordering of various features found in responders, meaning they will always appear the same across all responders. The best thing about it is that if I feel like changing the order, I can do that on the level of this extension, and it will automatically apply throughout the whole game. I've also solved some other problems with formatting on responders, just very niche issues relating to how dividers (empty space) are inserted into lists of actions. Previously, this had a few edge cases where it would produce dividers in places where they shouldn't be, though you'd not see this as it only happens in the more advanced fragment responders used during exploration. These were just things that began bothering me in the case of the interactions we've been building for the test adventure.

Now, for the main thing. People tend to call me a lot of different things: "a programmer", "cat", "[censored]", etc. But this largely ignores that I'm a mathematician and like putting math in some of my lore. Shockingly, HTML offers very little support for mathematical expression.


(The built-in <sub> and <sup> tags in HTML, while they nominally serve the purpose of providing a subscript and superscript, you might note that they cannot align both together; they just appear one after the other.)

The best-case scenario would be some kind of integration for either LaTeX or MathML. Unfortunately, the first just isn't available, and the second entered standard in 2023 and is not available for the engine we use for rendering. Some JS libraries serve to fill this hole, but I've yet to find one that works well for my purposes. For example, this week, I struggled to get MathJax to work, but... well...


(While it technically does work, the rendering quality leaves much to be desired.)


(This can be fixed by adding 20000 files to the game, which cannot be compressed, or handling it through CDN. Neither is an option I am willing to entertain. If you are curious about what's happening here... It's fonts/special SVG symbols for rendering, particularly the resizable elements like integrals or brackets.)

So you know what? I just made my own, which uses exclusively HTML for the rendering so that it can be used for documents in the game without worrying about any peculiarities of JS or CDNs. And sure, I fully acknowledge it's not as good. But it's better for what I need it for. You're not going to write your dissertation in theoretical physics using this, but I'm going to absolutely use this to express some of the concepts relevant to the game, inside of the game (see: verisimilitude*). Also, please note that I'm using Times New Roman to demonstrate this feature. This font is used by default in our documents, but it's causing minor issues because it has a strange alignment of mathematical operators (they don't align to the middle line). Unfortunately, this means I will need to reconsider its use.

I started with the proper subscript and superscript since this is the most helpful feature. As you can see, unlike the built-in HTML version, this aligns itself with the left side.


Then I moved on to over-script and under-script, another handy feature often used to express quantifiers or limits.


This was already a lot, but it would help if the subscript and superscript were more separated for some symbols. This also introduced scaling for symbols that might need a push to be a little bigger.


Another feature I wanted was fractions, and I also introduced a similar notation for binominals. Do note that this uses scaling brackets, a small nightmare to implement in their own right, especially when using nothing more than HTML, but it works well enough. I've used brackets before but didn't pay much attention to it; it's how the absolute value from before was denoted.


We can do more with those scaling brackets, especially if we combine them with matrix/grid notation:


And finally, for no reason other than I could, I added radicals:


While it doesn't handle heavy stacking too well (it doesn't matter; stacking should be avoided anyway), it has near-parity with LaTeX equation syntax. And it also has all the features I've ever used in writing, which is the most important thing here.

Next week might be particularly rough since I have work and medical appointments, but I'll see what I can do for the game.

*) Ah, you might wonder what this has to do with verisimilitude. In essence, when magic is a fundamental force of a fictional universe, there can be nothing making a rigid distinction between magic and science. In this case, the language of science can make its way into discussions of magic and, really, what else is the language of science if not math?

Get Esoteric ♥ Esoterica

Leave a comment

Log in with itch.io to leave a comment.