Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape the (hash) # sign in a Github markdown header? (backslash is not working)

I have the following code on a README.md file on Github, where I am trying to display the hash sign on a header (I am trying to escape it using the \ symbol) like so:

### C\# * [Beginning Game Programming with C#](https://www.coursera.org/course/gameprogramming) 

However it renders like so:

Not good

I obviously want the hash sign to appear on the header, and I also tried to use a double backslash, but it didn't work. How do I get the pound sign to appear?

EDIT: the linked question deals with github links, my question is to do with headers on a .md file.

like image 253
ifma Avatar asked Aug 25 '15 06:08

ifma


People also ask

How do you escape a hash character in markdown?

In Markdown, you can escape various characters using a backslash ( \ ), so if you wanted to type C#, you would use C\# .

Is Hash allowed in URL?

In a URL, a hash mark, number sign, or pound sign ( # ) points a browser to a specific spot in a page or website. It is used to separate the URI of an object from a fragment identifier. When you use a URL with a # , it doesn't always go to the correct part of the page or website.

What is the difference between encodeURI and encodeURIComponent?

The difference between encodeURI and encodeURIComponent is encodeURIComponent encodes the entire string, where encodeURI ignores protocol prefix ('http://') and domain name. encodeURIComponent is designed to encode everything, where encodeURI ignores a URL's domain related roots.

How do I encode a percentage?

Percent-encoding is a mechanism to encode 8-bit characters that have specific meaning in the context of URLs. It is sometimes called URL encoding. The encoding consists of substitution: A '%' followed by the hexadecimal representation of the ASCII value of the replace character.


2 Answers

You could try and add a matching '#', followed by one extra '#':

### C# # 
like image 199
VonC Avatar answered Sep 16 '22 15:09

VonC


You can also use # in place of the # symbol (based on this meta answer).

Or, as in this answer you can insert an invisible character before the octothorp, such as ​.

like image 24
shim Avatar answered Sep 20 '22 15:09

shim