fix: fix list with no items looping forever (#3560)
* fix: fix list with no items looping forever * add test
This commit is contained in:
parent
10020d018d
commit
e4198ed70d
@ -418,6 +418,9 @@ export class _Tokenizer {
|
||||
if (lastItem) {
|
||||
lastItem.raw = lastItem.raw.trimEnd();
|
||||
lastItem.text = lastItem.text.trimEnd();
|
||||
} else {
|
||||
// not a list since there were no items
|
||||
return;
|
||||
}
|
||||
list.raw = list.raw.trimEnd();
|
||||
|
||||
|
@ -127,6 +127,20 @@ describe('marked unit', () => {
|
||||
assert.strictEqual(html, '<p>Not Underlined A</p>\n<u>Underlined B</u>\n<p>Not Underlined C\n:Not Underlined D</p>\n');
|
||||
});
|
||||
|
||||
it('should not return list if no items', () => {
|
||||
const noHr = {
|
||||
tokenizer: {
|
||||
hr() {
|
||||
return undefined;
|
||||
},
|
||||
},
|
||||
};
|
||||
marked.use(noHr);
|
||||
const markdown = '- - -';
|
||||
const html = marked.parse(markdown);
|
||||
assert.strictEqual(html, '<p>- - -</p>\n');
|
||||
});
|
||||
|
||||
it('should use custom inline tokenizer + renderer extensions', () => {
|
||||
const underline = {
|
||||
name: 'underline',
|
||||
|
Loading…
x
Reference in New Issue
Block a user