markup icon indicating copy to clipboard operation
markup copied to clipboard

@ character is not escapable

Open spixi opened this issue 7 years ago • 22 comments

User Story

As a GitHub user I want to make @ characters escapable to avoid the automatic mentioning of users.

Problem

In GitHub issue comments it is not possible to escape the @ character with the backslash. This may lead to unintended mentioning of other users. It is however possible to use the grave (`@`) or the zero width space (U+200B). Since the ZWSP is hard to find after you copy a table, I do not recommend it here. I first noticed the bug this issue.

Examples

Syntax Example Expected behavior Actual behavior
@spixi @spixi mention link mention link
\@spixi @spixi no mention link mention link
`@spixi` @spixi no mention link no mention link
@​spixi with ZWSP @​spixi no mention link no mention link

spixi avatar Mar 06 '18 20:03 spixi

Commonmark, unlike Gruber's original Markdown, allows all punctuation chars in U+0020..7F to be escaped with the backslash. Alas, Github's at-mention extension apparently works as a postprocessor on top of cmark-gfm and is not a part of its Autolinks extension.

Crissov avatar Mar 08 '18 11:03 Crissov

Indeed, we do postprocess to add @mentions to a document. By the time the \@ makes it to the part of the code that links users, the backslash has already been eaten by our Markdown processor. (I've been known to use the ZWSP trick myself.)

If CommonMark didn't allow escaping all punctuation in ASCII with a backslash, the Markdown processor would leave the backslash alone, and then we could detect it in the postprocess stage. If we added an exception here, we'd no longer be CommonMark-compliant — the documents @ and \@ should render identically.

There's no simple solution here, unfortunately.

kivikakk avatar Aug 30 '18 07:08 kivikakk

Found an easy way to escape at signs! E.g.: @chloekek. This doesn't insert code markup or ZWSPs.

@<!-- -->chloekek

zopsicle avatar May 22 '19 19:05 zopsicle

@chloekek Nice finding. <!-- --> is used for comments in SGML and does not seem to be part of vanilla Markdown. Could this somewhere added to the help page?

spixi avatar May 22 '19 21:05 spixi

(I've been known to use the ZWSP trick myself.)

@kivikakk What is the "ZWSP trick"? Zero-width space?

@chloekek Great solution!

@kivikakk See @spixi's suggestion that this get added to the help page. Zero-width spaces is a huge pain to type and interrupts the thought process while trying to compose messages.

jzabroski avatar Nov 12 '19 15:11 jzabroski

@jzabroski Yes, it stands for zero-width space.

I didn't write or have input on the docs — might need to get in touch with @github/product-docs-core? (This is a guess, sorry if I'm @mention'ing the wrong team!)

kivikakk avatar Nov 12 '19 21:11 kivikakk

@github/product-docs-core is the right team! First responder here... I opened https://github.com/github/help-docs/issues/11534 to track this issue. 😊

lecoursen avatar Nov 13 '19 13:11 lecoursen

Just want to add a real-world use-case for this feature, which is that the JSON-LD spec has various keywords that begin with the @ symbol, e.g. @context, @id, @type, etc. When discussing these on GitHub it's all too easy to not backtick them and then you have user mentions everywhere. (This is also happening in commit messages that reference these terms, though I don't really expect people to escape @ in commit messages.)

tobek avatar Aug 05 '20 06:08 tobek

Another use case: SCSS has a variety of @-rules that it would be nice to be able to mention in issues without pinging the corresponding users.

broofa avatar May 09 '22 18:05 broofa

Hey! I found this (‎ ‎‎‎‎‎). Thus I could add ``` into my code block on my readme.md file 😁

BeratTezer avatar Dec 07 '22 22:12 BeratTezer