How to use wix fonts on custom HTML

After fighting this myself, instead of
element.html = <span>my custom generated content</span>;
(which loses the formatting without a clean way to add it back) put pre-formatted placeholder text in your element, and use
element.html = element.html.replace("my placeholder text", "my custom generated content");
which seems to retain the formatting for the replaced text.

I’d rather not need to hack around platform limitations, but here we are.