Skip to content

Extra space in label #13

@catchmeifyoutry

Description

@catchmeifyoutry

The parser seems to include the space that occurs immediately after the checkbox into the label.

Problem

When I try the example from the README, md.render('- [x] unchecked') ,

  • the output I see: ...<label for="cbx_0"> unchecked</label>... (note the space before unchecked)
  • the output I expected: ...<label for="cbx_0">unchecked</label>... (no space)

So, the output is slightly different from what the README shows.
Intuitively, it also does not make sense to include the space, since it is just part of the syntax to separate the checkbox from the actual label content (even the startsWithTodoMarkdown() regards this space as part of the required syntax) .

I tried using this plugin in combination with prosemirror-markdown which only uses markdown-it to parse the text but not to render HTML. It turns out the space is already present in the tokens generated by markdown-it-task-checkbox.

Fix

Concretely, I could track the problem down to slice(3); in line 63, which just removes the first 3 characters, i.e. [x]. Changing this to slice(4); fixes the problem for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions