markdown-it-task-checkbox icon indicating copy to clipboard operation
markdown-it-task-checkbox copied to clipboard

XHTML output improperly self-closing DIV

Open richardtallent-erm opened this issue 2 years ago • 0 comments

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:

https://github.com/linsir/markdown-it-task-checkbox/blob/6c684bb3f02aa097fe33ca7d9fe05e19857c910d/index.js#L69

Reference to the MarkdownIt issue:

https://github.com/markdown-it/markdown-it/issues/911

richardtallent-erm avatar Jan 12 '23 19:01 richardtallent-erm