Skip to content

Commit

Permalink
revert tests, add condition for blockquotes
Browse files Browse the repository at this point in the history
  • Loading branch information
BrtqKr committed May 27, 2024
1 parent 106b78b commit 5131c1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,15 +1040,15 @@ test('Test quotes markdown replacement and removing <br/> from <br/><pre> and </
expect(parser.replace(testString)).toBe(resultString);
});

test('Test quotes markdown replacement including blank quotes', () => {
test('Test quotes markdown replacement skipping blank quotes', () => {
const testString = '> \n>';
const resultString = '<blockquote></blockquote>';
const resultString = '&gt; <br />&gt;';
expect(parser.replace(testString)).toBe(resultString);
});

test('Test quotes markdown replacement with text starts with blank quote', () => {
const testString = '> \ntest';
const resultString = '<blockquote></blockquote>test';
const resultString = '&gt; <br />test';
expect(parser.replace(testString)).toBe(resultString);
});

Expand Down Expand Up @@ -1078,7 +1078,7 @@ test('Test quotes markdown replacement with quotes includes multiple middle blan

test('Test quotes markdown replacement with text includes blank quotes', () => {
const testString = '> \n> quote1 line a\n> quote1 line b\ntest\n> \ntest\n> quote2 line a\n> \n> \n> quote2 line b with an empty line above';
const resultString = '<blockquote>quote1 line a<br />quote1 line b</blockquote>test<br /><blockquote></blockquote>test<br /><blockquote>quote2 line a<br /><br /><br />quote2 line b with an empty line above</blockquote>';
const resultString = '<blockquote>quote1 line a<br />quote1 line b</blockquote>test<br />&gt; <br />test<br /><blockquote>quote2 line a<br /><br /><br />quote2 line b with an empty line above</blockquote>';
expect(parser.replace(testString)).toBe(resultString);
});

Expand Down
5 changes: 3 additions & 2 deletions lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,11 @@ export default class ExpensiMark {
// block quotes naturally appear on their own line. Blockquotes should not appear in code fences or
// inline code blocks. A single prepending space should be stripped if it exists
process: (textToProcess, replacement, shouldKeepRawInput = false) => {
const regex = /^(?:&gt;)+ +(?! )(?![^<]*(?:<\/pre>|<\/code>))([^\v\n\r]*)/gm;
const regex = /^(?:&gt;)+ +(?! )(?![^<]*(?:<\/pre>|<\/code>))([^\v\n\r]+)/gm;
const replaceFunction = (g1) => replacement(g1, shouldKeepRawInput);
if (shouldKeepRawInput) {
return textToProcess.replace(regex, replaceFunction);
const rawInputRegex = /^(?:&gt;)+ +(?! )(?![^<]*(?:<\/pre>|<\/code>))([^\v\n\r]*)/gm;
return textToProcess.replace(rawInputRegex, replaceFunction);
}
return this.modifyTextForQuote(regex, textToProcess, replacement);
},
Expand Down

0 comments on commit 5131c1b

Please sign in to comment.