Writing Template Strings in Markdown

With template strings, the backtick (`) means something in Markdown and in JavaScript. This:

To display a message, write `alert(`hello world!`)`.

will result in:

To display a message, write alert(hello world!).

To avoid this, we can leverage a little-known feature that’s been in Markdown from the beginning: you can use multiple backticks as code delimiters, like this:

To display a message, write ``alert(`hello world!`)``.

This will now render things correctly:

To display a message, write alert(`hello world!`).

Spread the word on BlueskyEdit on GithubPublished on Jan 30, 2020

Copyright © 2019...2025 Nick Plekhanov