What are the complete syntax rules for emphasis?

Can someone point me to all the rules about bold and italic text in GitHub Flavored Markdown? I already found two surprises:

  • An underscore after a letter doesn’t begin italic text. Try _italic_ but_not italic_
  • An asterisk after a letter and before a parenthesis doesn’t begin italic text. Try regular*italic* but*(why not italic?)*

Hi @italicize,

GitHub uses CommonMark as the Markdown processor, so you can view all of the rules for emphasis in the CommonMark specifications.

Does this help?



The complete specification has 17 rules about when emphasis begins and ends. To summarize, I wrote three rules for myself:

  1. Use either asterisks or underscores to emphasize a character next to a space, punctuation, or the beginning or end of a line. Put an emphasis mark immediately next to a character, with no space between.
  • Exception. Special punctuation marks override this rule, including a backslash, backtick, and square brackets which cause an asterisk or underscore to be rendered as a character and ignored as an emphasis mark.
  1. Use an asterisk to emphasize letters and numbers next to letters and numbers. By contrast, an underscore is not an emphasis mark between letters and numbers, as in not_italic.
  2. To emphasize punctuation next to letters and numbers, use HTML tags. By contrast, an asterisk and underscore cannot emphasize punctuation next to an unemphasized letter or number.

To see these rules with examples, see Emphasis in GitHub Flavored Markdown.