diff --git a/app/Resources/Viewer/scripts/discord.js b/app/Resources/Viewer/scripts/discord.js index f9a2d1a..71e96b7 100644 --- a/app/Resources/Viewer/scripts/discord.js +++ b/app/Resources/Viewer/scripts/discord.js @@ -1,7 +1,7 @@ const DISCORD = (function() { const regex = { formatBold: /\*\*([\s\S]+?)\*\*(?!\*)/g, - formatItalic: /(.)?\*([\s\S]+?)\*(?!\*)/g, + formatItalic: /(.)?([_*])([\s\S]+?)\2(?!\2)/g, formatUnderline: /__([\s\S]+?)__(?!_)/g, formatStrike: /~~([\s\S]+?)~~(?!~)/g, formatCodeInline: /(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/g, @@ -9,7 +9,7 @@ const DISCORD = (function() { formatUrl: /(\b(?:https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, formatUrlNoEmbed: /<(\b(?:https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])>/ig, specialEscapedBacktick: /\\`/g, - specialEscapedSingle: /\\([*\\])/g, + specialEscapedSingle: /\\([*_\\])/g, specialEscapedDouble: /\\__|_\\_|\\_\\_|\\~~|~\\~|\\~\\~/g, specialUnescaped: /([*_~\\])/g, mentionRole: /<@&(\d+?)>/g, @@ -47,8 +47,8 @@ const DISCORD = (function() { .replace(regex.specialEscapedSingle, escapeHtmlMatch) .replace(regex.specialEscapedDouble, full => full.replace(/\\/g, "").replace(/(.)/g, escapeHtmlMatch)) .replace(regex.formatBold, "$1") - .replace(regex.formatItalic, (full, pre, match) => pre === "\\" ? full : (pre || "") + "" + match + "") .replace(regex.formatUnderline, "$1") + .replace(regex.formatItalic, (full, pre, char, match) => pre === "\\" ? full : (pre || "") + "" + match + "") .replace(regex.formatStrike, "$1"); }