Only use backslash escapes in autocomplete when needed
What does this MR do?
Autocompletion for references happens on the frontend. Those references are turned into actual references on the backend, but only after Markdown processing has happened. That means that if a reference contains a character that Markdown might consume, it won't render correctly. So we need to do some escaping on the frontend.
We have these potential problem characters: https://docs.gitlab.com/ee/user/markdown.html#emphasis
~- this is
strikethrough, but only when doubled.
_- used for emphasis, doubled is bold.
*- also used for emphasis, doubled is bold also.
`- used for
code spans, any number works.
We don't need to escape
- any more. When it comes to being inside a
b(has strikethrough), so it needs to be escaped everywhere.
a_b_-> a_b_ (no emphasis, see https://docs.gitlab.com/ee/user/markdown.html#multiple-underscores-in-words), so it only needs to be escaped at the start and end of words.
a*b*-> ab (emphasis), so it needs to be escaped everywhere.
b(code span), so it needs to be escaped everywhere.
Closes #45348 (closed).