Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix space removed after checkbox #2971

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Parser.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ describe('inlineLexer', () => {
});
});

describe('task', () => {
UziTech marked this conversation as resolved.
Show resolved Hide resolved
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
Loading