Escape pound or number sign in Github issue tracker

You can use the following:

<span>#</span>1

I was quite surprised that the following did not work:

&#0035;1

short answer

choose from this list:

#&#x2060;1           ⯇ # — <invisible character> — 1

<span>#</span>1

<i>#</i>1           ⯇ the number sign will be italic

\# 1

#⁠1           ⯇ you need to copy-paste this!
                     # — <invisible character> — 1
                     even works for commit messages.


more generic answer

These are the options you have:

  • Option A: put any non-numeric ([0-9]+) UTF-8 character between # and the number
    • using the character itself (e.g. # 1) — this will even work in commit messages
    • using an HTML entity (e.g. #&nbsp;1) — useful for characters not on your keyboard
  • Option B: use formatting on either # or the number
    • using Markdown (e.g. #*1*)
    • using HTML tag (e.g. #<i>1</i>)
    • NOTE that not all formatting variants, especially the Markdown ones, do always work!

long answer

1    use a space character

You can put any kind of space character between # and the number.

1.a    word joiner — U+2060

This is the most unobtrusive solution:

  • #&#x2060;1 ⇒ #⁠1

In this case the space character is written as &#x2060;, that's the numeric character reference for the WORD JOINER unicode character [3].

The word joiner (WJ) is a zero width non-breaking space; that is, it's not visible (zero width) [4] and prevents # and the number from being separated by an automatic line break (non-breaking) [5].

1.b    regular space — U+0020 / no-break space — U+00A0

Of course you can use a "normal" space, which is faster to type than &#x2060;:

  • \# 1 ⇒ # 1

The backslash before the hash sign (\#) prevents the line from becoming a heading in case \# 1 is at the beginning of the line.

The \# 1 solution uses a breaking space. To use a non-breaking space, type instead: #&nbsp;1 (no backslash needed).

1.c    hint for advanced keyboard users

If you're using an ”advanced“ keyboard layout such as Colemak or Neo (german), you can use it to type special spaces — non-breaking spaces (NBSP) and narrow non-breaking spaces (NNBSP).

  • \# 1 ⇒ # 1    (NBSP)
  • \# 1 ⇒ # 1    (NNBSP)

2    use formatting

Besides the solution of putting an extra character between # and the number, you can use markdown or HTML formatting. Below I'm providing some examples. Some solutions are striked out because they do not work (anymore).

Please note that the functionality could change at any time in case GitHub changes its code.

  • using <span> (as stated by Sam Harwell)
    • <span>#</span>1 ⇒ #1
  • using italic font:
    • *#*1#1
    • <i>#</i>1#1
    • #*1* ⇒ #1
    • #<i>1</i> ⇒ #1
  • using strong font:
    • **#**1#1
    • <b>#</b>1#1
    • #**1** ⇒ #1
    • #<b>1</b> ⇒ #1
  • using single backticks:
    • `#1`#1
    • `#`1#1
    • #`1` ⇒ #1