Golo Roden
Golo Roden

Reputation: 150684

How do I add a trailing # (hash) to a header in GitHub flavored markdown?

I have a README.md markdown file that I use to describe a project that is hosted on GitHub. Within this file I have several headlines and sub-headlines, each starting with one or more hashes, as usual in markdown.

Now I want to set the text of one headline to C#, but GitHub does not respect the hash a part of the text, but interprets it as an (optional) closing hash for the headline.

Even if I escape the hash by prefixing it with a backslash, it does not work. So if I type

## C#

I get:

C

If I use

## C\#

I get:

C\

How do I write this head-line in a correct way?

Upvotes: 7

Views: 2623

Answers (2)

Andrew Smith
Andrew Smith

Reputation: 162

An alternative to try is adding another trailing # because they act like brackets on the line, so ## C# # or ## C# ## if you want to balance out the characters.

Upvotes: 1

Chris
Chris

Reputation: 46326

Method 1

You could use a true sharp sign, , instead of the hash sign, #. From the Wikipedia page on C♯:

By convention, a hash sign is used for the second character in normal text; in artistic representations, sometimes a true sharp sign is used: C♯.

Here ## C♯ produces

C♯

Method 2

Alternatively, (at least on this site) just put a space after the last #, for example ## C\# produces

C#

Note that Pandoc seems to handle # C\# correctly (try it).

Upvotes: 8

Related Questions