diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js index 45d7a9df..2d0e0a28 100644 --- a/lib/ExpensiMark.js +++ b/lib/ExpensiMark.js @@ -177,7 +177,7 @@ export default class ExpensiMark { { name: 'reportMentions', - regex: /(?$1', }, @@ -421,7 +421,7 @@ export default class ExpensiMark { { name: 'quote', regex: /<(blockquote|q)(?:"[^"]*"|'[^']*'|[^'">])*>([\s\S]*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))/gi, - replacement: (match, g1, g2) => { + replacement(match) { // We remove the line break before heading inside quote to avoid adding extra line let resultString = match .replace(/\n?(
with ">" function replaceBlockquotes(text) { - while (//i.test(text)) { - // Count how manytags - let depth = (text.match(//gi) || []).length; - // Replace all blockquote tags and add ">" per depth level - text = text.replace(//gi, ''); - text = text.replace(/<\/blockquote>/gi, ''); - return `${'>'.repeat(depth)} ${text}`; - } - return text; - } + let modifiedText = text; + let depth; + do { + depth = (modifiedText.match(//gi) || []).length; + modifiedText = modifiedText.replace(//gi, ''); + modifiedText = modifiedText.replace(/<\/blockquote>/gi, ''); + } while (//i.test(modifiedText)); + return `${'>'.repeat(depth)} ${modifiedText}`; + } return replaceBlockquotes(m); - }).join('\n'); + } + + resultString = _.map(resultString, processString).join('\n'); // We want to keeptag here and let method replaceBlockElementWithNewLine to handle the line break later return `${resultString}`;