mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 04:52:22 +00:00
5 lines
334 B
JavaScript
5 lines
334 B
JavaScript
module.exports = function escapeMarkdown(text, onlyCodeBlock = false, onlyInlineCode = false) {
|
|
if (onlyCodeBlock) return text.replace(/```/g, '`\u200b``');
|
|
if (onlyInlineCode) return text.replace(/\\(`|\\)/g, '$1').replace(/(`|\\)/g, '\\$1');
|
|
return text.replace(/\\(\*|_|`|~|\\)/g, '$1').replace(/(\*|_|`|~|\\)/g, '\\$1');
|
|
};
|