expensify-common 2.0.4 → 2.0.5
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.js +22 -2
- package/package.json +1 -1
package/dist/ExpensiMark.js
CHANGED
|
@@ -415,8 +415,28 @@ class ExpensiMark {
|
|
|
415
415
|
.replace(/(<h1>|<\/h1>)+/g, '\n')
|
|
416
416
|
.trim()
|
|
417
417
|
.split('\n');
|
|
418
|
-
|
|
419
|
-
|
|
418
|
+
// Wrap each string in the array with <blockquote> and </blockquote>
|
|
419
|
+
// Define a named function to wrap each line with blockquote
|
|
420
|
+
function wrapWithBlockquote(line) {
|
|
421
|
+
return `<blockquote>${line}</blockquote>`;
|
|
422
|
+
}
|
|
423
|
+
// Use _.map with the named function
|
|
424
|
+
resultString = _.map(resultString, wrapWithBlockquote);
|
|
425
|
+
function processString(m) {
|
|
426
|
+
// Recursive function to replace nested <blockquote> with ">"
|
|
427
|
+
function replaceBlockquotes(text) {
|
|
428
|
+
let modifiedText = text;
|
|
429
|
+
let depth;
|
|
430
|
+
do {
|
|
431
|
+
depth = (modifiedText.match(/<blockquote>/gi) || []).length;
|
|
432
|
+
modifiedText = modifiedText.replace(/<blockquote>/gi, '');
|
|
433
|
+
modifiedText = modifiedText.replace(/<\/blockquote>/gi, '');
|
|
434
|
+
} while (/<blockquote>/i.test(modifiedText));
|
|
435
|
+
return `${'>'.repeat(depth)} ${modifiedText}`;
|
|
436
|
+
}
|
|
437
|
+
return replaceBlockquotes(m);
|
|
438
|
+
}
|
|
439
|
+
resultString = _.map(resultString, processString).join('\n');
|
|
420
440
|
// We want to keep <blockquote> tag here and let method replaceBlockElementWithNewLine to handle the line break later
|
|
421
441
|
return `<blockquote>${resultString}</blockquote>`;
|
|
422
442
|
},
|