Giter Site home page Giter Site logo

markdown-it-task-checkbox's People

Contributors

arve0 avatar linsir avatar mrmurphy avatar rikuson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

markdown-it-task-checkbox's Issues

Will not render correctly if spaces in "[ ] " are non-breaking spaces

If either the space between [ and ], or the space after ] is a non-breaking space (ascii code 160), then it will not render the check-list correctly.

The reason for this issue, is that we have many people making content in markdown for our project, and some of them (probably using a Mac) inadvertently inserted non-breaking spaces (alt+space), and thus ended up with strange lists.

If the owner (@linsir) agrees that non-breaking spaces should be allowed, I can make a PR that allows for non-breaking spaces. If not, please just close this issue.

Indeterminate Checkbox

There's no means of creating an incomplete/indeterminate checkbox.

Because indeterminate can't be generated with straight html, it might not be feasible.

Documentation around Indeterminate Checkboxes

Ideally, the Markdown side might be represented as [-], then after the HTML is rendered, using JS for post-processing into indeterminate.

Extra space in label

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.

XHTML output improperly self-closing DIV

When using the xhtmlOut flag and the markdown-it-task-list plugin with the wrapper div option, the wrapper div is self-closed by markdown-it, so it no longer wraps the input and label, but the div's end tag is left as well, so the markup is invalid XHTML:

import MarkdownIt from "markdown-it"
import MarkdownItTaskCheckbox from "markdown-it-task-checkbox"

const xhtmlParser = MarkdownIt({
	html: true,
	xhtmlOut: true,
}).use(MarkdownItTaskCheckbox , { divWrap: true });
var html = xhtmlParser.render("- [ ] unchecked item 1");
console.log(html);
<ul class="task-list">
  <li class="task-list-item">
    <div class="checkbox" />
    <input type="checkbox" id="cbx_0" disabled="true" />
    <label for="cbx_0"> unchecked item 1</label>
    </div>
  </li>
</ul>

The MarkdownIt author quickly claimed that this is an issue with the plugin, not MarkdownIt. I'm not sure either way, as I'm not familiar enough with the plug-in API to know if your code below is calling MarkdownIt in some way that would result in this issue during XHTML output:

if (options.divWrap) {

Reference to the MarkdownIt issue:

markdown-it/markdown-it#911

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.