UNPKG

232 BJavaScriptView Raw
1// @flow
2const escapeCharacters = ['\\', '*', '_', '~'];
3
4export function escapeMarkdown(s: string): string {
5 for (const char of escapeCharacters) {
6 s = s.replace(new RegExp(`\\${char}`, 'g'), `\\${char}`);
7 }
8
9 return s;
10}