diff --git a/__tests__/ExpensiMark-Markdown-test.js b/__tests__/ExpensiMark-Markdown-test.js index a8bf1769..093f5ca5 100644 --- a/__tests__/ExpensiMark-Markdown-test.js +++ b/__tests__/ExpensiMark-Markdown-test.js @@ -497,6 +497,18 @@ test('map div with quotes', () => { expect(parser.htmlToMarkdown(testString)).toBe(resultString); }); +test('double quotes in same line', () => { + const testString = '
'; + const resultString = '>> line 1'; + expect(parser.htmlToMarkdown(testString)).toBe(resultString); +}); + +test('triple quotes in same line', () => { + const testString = 'line 1
'; + const resultString = '>>> line 1'; + expect(parser.htmlToMarkdown(testString)).toBe(resultString); +}); + test('map table to newline', () => { const testString = 'line 1
and+ // Define a named function to wrap each line with blockquote + function wrapWithBlockquote(line) { + return `
${line}`; + } + + // Use _.map with the named function + resultString = _.map(resultString, wrapWithBlockquote); + + function processString(m) { + // Recursive function to replace nested
with ">" + function replaceBlockquotes(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); + } + + resultString = _.map(resultString, processString).join('\n'); + // We want to keeptag here and let method replaceBlockElementWithNewLine to handle the line break later return `${resultString}`; },