expensify-common
Advanced tools
Comparing version 2.0.5 to 2.0.6
@@ -280,16 +280,16 @@ "use strict"; | ||
}, | ||
/** | ||
* Use \b in this case because it will match on words, letters, | ||
* and _: https://www.rexegg.com/regex-boundaries.html#wordboundary | ||
* Use [\s\S]* instead of .* to match newline | ||
*/ | ||
{ | ||
/** | ||
* 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: /(?<!<[^>]*)(\b_+|\b)(?!_blank")_((?![\s_])[\s\S]*?[^\s_](?<!\s))_(?![^\W_])(?![^<]*>)(?![^<]*(<\/pre>|<\/code>|<\/a>|<\/mention-user>|_blank))/g, | ||
// We want to add extraLeadingUnderscores back before the <em> tag unless textWithinUnderscores starts with valid email | ||
replacement: (match, extraLeadingUnderscores, textWithinUnderscores) => { | ||
regex: /(<(pre|code|a|mention-user)[^>]*>(.*?)<\/\2>)|((\b_+|\b)_((?![\s_])[\s\S]*?[^\s_](?<!\s))_(?![^\W_])(?![^<]*>)(?![^<]*(<\/pre>|<\/code>|<\/a>|<\/mention-user>)))/g, | ||
replacement: (match, html, tag, content, text, extraLeadingUnderscores, textWithinUnderscores) => { | ||
// Skip any <pre>, <code>, <a>, <mention-user> tag contents | ||
if (html) { | ||
return html; | ||
} | ||
// If any tags are included inside underscores, ignore it. ie. _abc <pre>pre tag</pre> abc_ | ||
if (textWithinUnderscores.includes('</pre>') || this.containsNonPairTag(textWithinUnderscores)) { | ||
@@ -296,0 +296,0 @@ return match; |
{ | ||
"name": "expensify-common", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"author": "Expensify, Inc.", | ||
@@ -5,0 +5,0 @@ "description": "Expensify libraries and components shared across different repos", |
476894