fix: fix space removed after checkbox (#2971)

* fix: fix space removed after checkbox

* add loose test
This commit is contained in:
Tony Brix 2023-09-06 12:57:09 -06:00 committed by GitHub
parent 0ac8b78fe7
commit 9a2a4ad61a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -141,11 +141,11 @@ export class _Parser {
} else {
item.tokens.unshift({
type: 'text',
text: checkbox
text: checkbox + ' '
} as Tokens.Text);
}
} else {
itemBody += checkbox;
itemBody += checkbox + ' ';
}
}

View File

@ -33,6 +33,20 @@ describe('inlineLexer', () => {
});
});
describe('task', () => {
it('space after checkbox', () => {
const html = marked('- [ ] item');
expect(html).toBe('<ul>\n<li><input disabled="" type="checkbox"> item</li>\n</ul>\n');
});
it('space after loose checkbox', () => {
const html = marked('- [ ] item 1\n\n- [ ] item 2');
expect(html).toBe('<ul>\n<li><p><input disabled="" type="checkbox"> \nitem 1</p>\n</li>\n<li><p><input disabled="" type="checkbox"> \nitem 2</p>\n</li>\n</ul>\n');
});
});
describe('parseInline', () => {
it('should parse inline tokens', () => {
const md = '**strong** _em_';