Ok, that was extremely helpful. Looking at
https://manual.calibre-ebook.com/template_lang.html I coudln't figure it out, because that whole page is written for SFM and I've had a hard time finding any documentation of the other two other than a few lines of examples that I coudln't make sense of.
I feel like the above page should have most of your above message either inserted at the top or right after the "advanced formatting" heading.