How to Format Money in Markdown
This seems like something I should already know and can’t believe I’m only now running into a situation where I need to enter a dollar figure in Markdown after writing it all these years.
Here’s the deal: Type a dollar sign before a number and Markdown formats the content like this:
Apparently $
is used by some sort of “math mode” called MathJax? And it’s used for formatting complex mathematical formulas of the sort that only my college roommate who majored in Quantum Physics can look at and go, Oooooo.
Only, maybe it’s not MathJax under the hood. I haven’t installed it as a VS Code extension, at least intentionally or anything li… oh wait.
Oh. I did indeed install an extension that enables math formatting in Markdown out of the box. It ain’t MathJax but Markdown+Math baked into the extension. This is totally one of those cases of not fully knowing what I’m adding to my stack. Which is a great reminder to completely read things before I wholeheartedly adopt them. This one is of no consequence, really, but it might have been in a different kind of project under different conditions.
Right, right, the solution. It’s easy. Prepend a backslash to the dollar sign and you’re good to go. Seems so obvious once I stop to think about it.
\$105 million
The more you know. ????
1 Comments
For a few years now, VS Code has actually supported this without any extensions – see VS Code v1.58 Release Notes. It uses KaTex as the rendering engine, rather than MathJax, but the syntax is the same, being based on TeX/LaTeX.