mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
756 stars 138 forks source link

write task lists to HTML #133

Closed ec1oud closed 3 years ago

ec1oud commented 3 years ago

For a markdown task list:

- [ ] some task to do
- [x] some task already done

github generates disabled checkboxes somehow, and the firefox inspector tells me they are actual disabled checkbox input elements.

But I keep wondering what is the simplest HTML that Qt could support converting to and from. We don't support HTML forms, thus we don't support the <input> tag at all. In a browser, this renders OK:

<ul>
<li><label><input type="checkbox" id="task1" disabled/>Some task to do</label></li>
<li><label><input type="checkbox" id="task1" disabled checked/>Some task already done</label></li>
</ul>

So does this:

<ul>
<li><input type="checkbox" id="task1" disabled/>Some task to do</li>
<li><input type="checkbox" id="task1" disabled checked/>Some task already done</li>
</ul>

But with the bullet characters showing in front of the checkboxes, in both cases.

md2html generates

<ul>
<li>[ ] some task to do</li>
<li>[x] some task already done</li>
</ul>

which could be improved somehow.

Another idea would be to use unicode checkbox characters: ☑ BALLOT BOX WITH CHECK and ☐ BALLOT BOX. But in Qt if you import html, it would be a bit weird to make that special case: if a list item begins with one of those characters, it becomes a list item with a checkbox marker rather than keeping the unicode text intact. It could work, but maybe we'd better start supporting <input>, but then somebody might complain that we only support checkboxes, not even the form tag.

So I wonder if you have any better ideas?

ec1oud commented 3 years ago

Ah I forgot the --github command line option to md2html. Then we get

<ul>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled>some task to do</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled checked>some task already done</li>
</ul>

which is fine. Qt should do the same, I suppose.