Skip to content

Commit

Permalink
fix: fix space removed after checkbox (#2971)
Browse files Browse the repository at this point in the history
* fix: fix space removed after checkbox

* add loose test
  • Loading branch information
UziTech committed Sep 6, 2023
1 parent 0ac8b78 commit 9a2a4ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Parser.ts
Expand Up @@ -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 + ' ';
}
}

Expand Down
14 changes: 14 additions & 0 deletions test/unit/marked-spec.js
Expand Up @@ -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_';
Expand Down

1 comment on commit 9a2a4ad

@vercel
Copy link

@vercel vercel bot commented on 9a2a4ad Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.