header-composer-inserter? I just met her!
Right after the yesterday's commemorate achievement of launching a webhook I had to start studying for the oncoming colloquium. For those unfamiliar with what colloquim is: it's a superior form of knowledge control. Most probably learn about the same from 2-3 hours there as from the rest of the semester.
One of the problems posed for the colloquium was eye-opening for me. So much in fact that I wanted to make an article about it. But this would mean I'll have to be able to display equations. On the old website I used MathJax to render LaTeX equation. But this has downsides, the most prominent one of which is I don't want to type equations in LaTeX. I would prefer typst's syntax 24/7 365 days in a year for my whole life. The other reason is that MathJax approach needs MathJax to render every time, which doesn't sound very reliable and not at all customizable.
So I had a concept that I successfully implemented and would like to share.
The idea is the following:
So as a proof of concept I made some simple scripts and surprisingly they worked as wanted almost first try! Had to ask DeepSeek about regex, but that's about it.
For anyone interested I posted a code on my github. It'll need further improvement and I am looking forward to hearing your suggestions but it works!
So as I am writing this article, say I need to insert an equation. Let's pick a long one.
<!--
$ln((k_1(epsilon))/(k_1(epsilon^0))) = e^2/(4 pi epsilon_0 2 k T)(1/epsilon 1/epsilon^0)(Z_A^2/r_A + Z_B^2/r_B - (Z_A + Z_B)^2/r^eq.not)$< born >
-->
Then I go to eq-to-svg.py and just run it. Ending up with this
<!--
$ln((k_1(epsilon))/(k_1(epsilon^0))) = e^2/(4 pi epsilon_0 2 k T)(1/epsilon 1/epsilon^0)(Z_A^2/r_A + Z_B^2/r_B - (Z_A + Z_B)^2/r^eq.not)$< born >
-->
<div class="equation">
<img src="./assets/typ/born.svg" alt="ln((k_1(epsilon))/(k_1(epsilon^0))) = e^2/(4 pi epsilon_0 2 k T)(1/epsilon 1/epsilon^0)(Z_A^2/r_A + Z_B^2/r_B - (Z_A + Z_B)^2/r^eq.not)">
</div>
Now here is the result:
Oh wait! Nooo way. I forgot the minus before the 1/epsilon^0 term. No minus? No problem. Just add it and run the script again to gain the following.
Have you noticed the equation color is the same as the left border of the quote? That's because the header-composer-inserter.py (which makes and inserts a styling header into the .typ files) took the color variable from the website's css!
There are other cool details included like indent matching and you may have noticed the alt being composed on the way. So just as I said, it's quite customizable and independent. I'll try to make this setup more compact and optimized.
Oh and stay tuned for the kinetics article!