expensify-common 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/ExpensiMark.js +12 -12
  2. package/package.json +1 -1
@@ -277,20 +277,20 @@ class ExpensiMark {
277
277
  return `<blockquote>${isStartingWithSpace ? ' ' : ''}${replacedText}</blockquote>`;
278
278
  },
279
279
  },
280
+ /**
281
+ * Use \b in this case because it will match on words, letters,
282
+ * and _: https://www.rexegg.com/regex-boundaries.html#wordboundary
283
+ * Use [\s\S]* instead of .* to match newline
284
+ */
280
285
  {
281
- /**
282
- * Use \b in this case because it will match on words, letters,
283
- * and _: https://www.rexegg.com/regex-boundaries.html#wordboundary
284
- * The !_blank is to prevent the `target="_blank">` section of the
285
- * link replacement from being captured Additionally, something like
286
- * `\b\_([^<>]*?)\_\b` doesn't work because it won't replace
287
- * `_https://www.test.com_`
288
- * Use [\s\S]* instead of .* to match newline
289
- */
290
286
  name: 'italic',
291
- regex: /(?<!<[^>]*)(\b_+|\b)(?!_blank")_((?![\s_])[\s\S]*?[^\s_](?<!\s))_(?![^\W_])(?![^<]*>)(?![^<]*(<\/pre>|<\/code>|<\/a>|<\/mention-user>|_blank))/g,
292
- // We want to add extraLeadingUnderscores back before the <em> tag unless textWithinUnderscores starts with valid email
293
- replacement: (match, extraLeadingUnderscores, textWithinUnderscores) => {
287
+ regex: /(<(pre|code|a|mention-user)[^>]*>(.*?)<\/\2>)|((\b_+|\b)_((?![\s_])[\s\S]*?[^\s_](?<!\s))_(?![^\W_])(?![^<]*>)(?![^<]*(<\/pre>|<\/code>|<\/a>|<\/mention-user>)))/g,
288
+ replacement: (match, html, tag, content, text, extraLeadingUnderscores, textWithinUnderscores) => {
289
+ // Skip any <pre>, <code>, <a>, <mention-user> tag contents
290
+ if (html) {
291
+ return html;
292
+ }
293
+ // If any tags are included inside underscores, ignore it. ie. _abc <pre>pre tag</pre> abc_
294
294
  if (textWithinUnderscores.includes('</pre>') || this.containsNonPairTag(textWithinUnderscores)) {
295
295
  return match;
296
296
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expensify-common",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "author": "Expensify, Inc.",
5
5
  "description": "Expensify libraries and components shared across different repos",
6
6
  "homepage": "https://expensify.com",