diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js index 855822c87..8e52b5f04 100644 --- a/lib/ExpensiMark.js +++ b/lib/ExpensiMark.js @@ -282,6 +282,15 @@ export default class ExpensiMark { return `
${isStartingWithSpace ? ' ' : ''}${replacedText}
`; }, }, + /** + * Use \b in this case because it will match on words, letters, + * and _: https://www.rexegg.com/regex-boundaries.html#wordboundary + * The !_blank is to prevent the `target="_blank">` section of the + * link replacement from being captured Additionally, something like + * `\b\_([^<>]*?)\_\b` doesn't work because it won't replace + * `_https://www.test.com_` + * Use [\s\S]* instead of .* to match newline + */ { name: 'italic', regex: /(<(pre|code|a|mention-user)[^>]*>(.*?)<\/\2>)|((\b_+|\b)_((?![\s_])[\s\S]*?[^\s_](?)(?![^<]*(<\/pre>|<\/code>|<\/a>|<\/mention-user>)))/g,