183

in markdown, my_stock_index is mystockindex. But I want it to show my_stock_index. How can do that?

GoingMyWay
  • 16,802
  • 32
  • 96
  • 149
  • 1
    Which implementation of Markdown are you using? – ChrisGPT was on strike Mar 06 '16 at 14:20
  • @Chris, Markdown Pad – GoingMyWay Mar 07 '16 at 05:00
  • @Chris do you mean that this isn't standard behavior? – lulalala Apr 12 '18 at 01:36
  • @lulalala, many Markdown questions on SO target some implementation other than [the original](https://daringfireball.net/projects/markdown/) and some common implementations handle this differently, e.g. [GitHub Flavored Markdown](https://github.github.com/gfm/#emphasis-and-strong-emphasis) and [GitLab Flavored Markdown](https://docs.gitlab.com/ee/user/markdown.html#multiple-underscores-in-words). – ChrisGPT was on strike Apr 12 '18 at 02:25

3 Answers3

248

You just escape it with a backslash: my\_stock\_ticker is what you type to get my_stock_ticker

The syntax seems to work for all markdown parsers. However, php markdown parsers use the numeric character reference _ instead of the actual character in it's output.

Steve Clanton
  • 4,064
  • 3
  • 32
  • 38
35

There is also the option to use backticks. This is actually used to refer to mark the text as inline code, but where else would you use underscores right? Besides it is much easier than managing the backslash stuff :)

`my_stock_index`
tacan
  • 450
  • 5
  • 4
30

The single backslash escape works fine in Jupyter unless you are in an italicized block, in which case, you want to close the italicized block, write the escaped underscore, then start the italicized block again.

_the cookie_\__cutter in italics_
Robert Casey
  • 1,511
  • 18
  • 19