Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use dollar signs ($) in a Markdown code block in a way that renders correctly when converted to HTML?

Tags:

html

markdown

I'm trying to write a block of code containing part of a Makefile script in a Markdown document.

If I write

<pre><code>FOO = $(BAR)
</code></pre>

then in multiple different Markdown previewers I'll see

FOO = $(BAR)

but when converted to HTML with various tools and opened in a browser, I see

FOO =

How can I write this such that it renders correctly in both a Markdown preview and in HTML?

Is it at all possible to use the 3-backtick (```) notation for code blocks in a way that works with HTML? I've found that it just literally prints the backticks when converted to HTML.

like image 293
superb owl Avatar asked Oct 15 '25 04:10

superb owl


2 Answers

Dollar sign can be printed using $\$$ This will be converted into a single '$' sign

like image 185
Abhijith Avatar answered Oct 18 '25 00:10

Abhijith


Consider using &#36; for $ when you use it within HTML.

like image 43
Anton Honcharuk Avatar answered Oct 17 '25 22:10

Anton Honcharuk