expensify-common 2.0.173 → 2.0.174
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.
- package/dist/ExpensiMark.d.ts +1 -0
- package/dist/ExpensiMark.js +17 -0
- package/package.json +1 -1
package/dist/ExpensiMark.d.ts
CHANGED
package/dist/ExpensiMark.js
CHANGED
|
@@ -128,6 +128,11 @@ class ExpensiMark {
|
|
|
128
128
|
const extraAttrs = attrCache && attrCache[videoSource];
|
|
129
129
|
return `<video data-expensify-source="${str_1.default.sanitizeURL(videoSource)}" data-raw-href="${videoSource}" data-link-variant="${typeof videoName === 'string' ? 'labeled' : 'auto'}" ${extraAttrs || ''}>${videoName ? `${videoName}` : ''}</video>`;
|
|
130
130
|
},
|
|
131
|
+
shouldSkipProcessing: (textToCheck) => {
|
|
132
|
+
const missingSpecialCharacters = !textToCheck.includes('!') || !textToCheck.includes('(') || !textToCheck.includes(')');
|
|
133
|
+
const missingVideoExtension = !Constants.CONST.VIDEO_EXTENSIONS.some((extension) => textToCheck.includes(`.${extension}`));
|
|
134
|
+
return missingSpecialCharacters || missingVideoExtension;
|
|
135
|
+
},
|
|
131
136
|
},
|
|
132
137
|
/**
|
|
133
138
|
* Apply inline code-block to avoid applying any other formatting rules inside of it,
|
|
@@ -208,6 +213,9 @@ class ExpensiMark {
|
|
|
208
213
|
const extraAttrs = attrCache && attrCache[imgSource];
|
|
209
214
|
return `<img src="${str_1.default.sanitizeURL(imgSource)}"${imgAlt ? ` alt="${this.escapeAttributeContent(imgAlt)}"` : ''} data-raw-href="${imgSource}" data-link-variant="${typeof imgAlt === 'string' ? 'labeled' : 'auto'}" ${extraAttrs || ''}/>`;
|
|
210
215
|
},
|
|
216
|
+
shouldSkipProcessing: (textToCheck) => {
|
|
217
|
+
return !textToCheck.includes('!') || !textToCheck.includes('(') || !textToCheck.includes(')');
|
|
218
|
+
},
|
|
211
219
|
},
|
|
212
220
|
/**
|
|
213
221
|
* Converts markdown style links to anchor tags e.g. [Expensify](https://www.expensify.com)
|
|
@@ -229,6 +237,9 @@ class ExpensiMark {
|
|
|
229
237
|
}
|
|
230
238
|
return `<a href="${str_1.default.sanitizeURL(g2)}" data-raw-href="${g2}" data-link-variant="labeled" target="_blank" rel="noreferrer noopener">${g1}</a>`;
|
|
231
239
|
},
|
|
240
|
+
shouldSkipProcessing: (textToCheck) => {
|
|
241
|
+
return !textToCheck.includes('.');
|
|
242
|
+
},
|
|
232
243
|
},
|
|
233
244
|
/**
|
|
234
245
|
* Apply the hereMention first because the string @here is still a valid mention for the userMention regex.
|
|
@@ -313,6 +324,9 @@ class ExpensiMark {
|
|
|
313
324
|
const href = str_1.default.sanitizeURL(g2);
|
|
314
325
|
return `${g1}<a href="${href}" data-raw-href="${g2}" data-link-variant="auto" target="_blank" rel="noreferrer noopener">${g2}</a>${g1}`;
|
|
315
326
|
},
|
|
327
|
+
shouldSkipProcessing: (textToCheck) => {
|
|
328
|
+
return !textToCheck.includes('.');
|
|
329
|
+
},
|
|
316
330
|
},
|
|
317
331
|
{
|
|
318
332
|
name: 'quote',
|
|
@@ -818,6 +832,9 @@ class ExpensiMark {
|
|
|
818
832
|
if (rule.pre) {
|
|
819
833
|
replacedText = rule.pre(replacedText);
|
|
820
834
|
}
|
|
835
|
+
if (rule.shouldSkipProcessing && rule.shouldSkipProcessing(replacedText)) {
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
821
838
|
const replacement = shouldKeepRawInput && rule.rawInputReplacement ? rule.rawInputReplacement : rule.replacement;
|
|
822
839
|
if ('process' in rule) {
|
|
823
840
|
replacedText = rule.process(replacedText, replacement, shouldKeepRawInput);
|