Most Markdown engines support escaping; that is, you can tell them to ignore Markdown formatting by putting a backslash before Markdown characters. For example in Github Flavoured Markdown: https://github.github.com/gfm/#backslash-escapes
This seems to be missing in the Rocket.Chat Markdown engine. It would be especially useful for web integrations that post messages in Rocket.Chat. For example, we have written an integration that automatically posts Redmine links when someone mentions an issue ID like #1234
; the integrations formats these links with Markdown, e.g.:
[Project - Error #1234: Subject](https://redmine.example.com/issues/1234)
Without quoting, special characters in the subject like ]
prevent Rocket.Chat from properly rendering the link.
Attempt to post special Markdown characters that are escaped with a backslash. For example, try to post a text containing asterisks, and prepend a backslash to prevent Rocket.Chat from interpreting this as "bold":
\*This is a test\*
Or try to post links that contains a verbatim ]
character:
[Project - Error #1234: Subject \]](https://redmine.example.com/issues/1234)
[Project - Error #1234: Subject \[test\]](https://redmine.example.com/issues/1234)
Rocket.Chat should display the first message like this (that is, verbatim asterisk, followed by test, followed by verbatim asterisk):
*test*
The links should be displayed like this:
Project - Error #1234: Subject ]
Project - Error #1234: Subject [test]
Rocket.Chat displays the first message like this:
\*test\*
And the links like this:
[Project - Error #1234: Subject \]](https://redmine.example.com/issues/1234)
Project - Error #1234: Subject =!=IfJbf9a34tKf2QEcg=!=
I don't even have the slightest idea what's happening with the second link, Rocket.Chat seems to replace the text in braces with a random string?! It kinda looks like a password, so I've replaced it with a randomly generated similar string just to be sure.
The last issue I mentied, the fact that RocketChat replaces text in backslashed braces with random password-like strings, also occurs in code blocks:
```
\[test\]
```
is displayed by RocketChat like this:
=!=z63FjnFNp8wqX5zMh=!=
instead of like this:
\[test\]
An example of this not rendering properly for escaped braces is here: https://open.rocket.chat/channel/support?msg=qQmNsdpvnqWAtSurC
I would suggest this is a bug, as there is no work around, and not an improvement request.
Regarding brackets within a Markdown URL definition, e.g.:
[Project - Error #1234: Subject [test]](https://redmine.example.com/issues/1234)
Manual escaping of the verbatim brackets by the user should not be necessary.
Instead, RocketChat's Markdown implementation should figure this out automatically.
The above URL should become:
Project - Error #1234: Subject [test]
I haven't figured out a workaround for KaTeX escaping the dollar sign for symbolic math as in below:
echo $dollar $hey
Same issue when needing to talk about *.xml & *.xsd files in a chat the rendering brings ".xml &" as bold, please provide a solution !
Something like *text* seems not possible. Here on github I can escape with \*text\*
.
Basic escaping would be awesome for all the formatting characters `*~_
I also would appreciate if basic escaping would be integrated.
I also would appreciate if basic escaping would be integrated.
I also would appreciate....... Wait isn't such a feature obvious in 2020 ? Some devs I swear...
We have a special issue with this. We use Rocket.chat in a german community that uses asterisks in their day-to-day communication ("gendern"). As you can imagine, this is very annoying.
It appears as if it all boils down to a single line doing unconditional replacing in a string:
for (const { token, text, noHtml } of tokenList) {
if (message.html.indexOf(token) >= 0) {
message.html = message.html.replace(token, () => (useHtml ? text : noHtml)); // Uses lambda so doesn't need to escape $
} else {
missingTokens.push({ token, text, noHtml });
}
}
Most helpful comment
Basic escaping would be awesome for all the formatting characters `*~_