mcecot / markdown-it-checkbox

Plugin to create checkboxes for markdown-it markdown parser.
MIT License
36 stars 22 forks source link

Convert back into markdown #8

Closed garygreen closed 9 years ago

garygreen commented 9 years ago

Is it possible to convert back into markdown? e.g.

<div classname="cb">
    <label>
        <input type="checkbox" id="cbx_0" checked>
        task 1
    </label>
    <label>
        <input type="checkbox" id="cbx_1">
        task 2
    </label>
</div>
md.toMarkdown(<html as above>) // outputs the below:
[*] task 1
[ ] task 2
mcecot commented 9 years ago

because this project is a plugin for markdown-it, i looked for a solution there. but i could not find any hint in the api that would suggest that html parsing is implemented. i close this ticket until markdown-it supports both ways, or someone comes up with a nice idea to implement this feature. in my opinion it should be a plugin for some package like html2markdown.

garygreen commented 9 years ago

I know it's a plugin, but imo this can be completely standalone tool that has no dependency on markdown-it. It simply uses regex to find the checkboxes and convert them to HTML -- not sure why it needs markdown-it?

For converting back into markdown, it's possible by simply finding what ones are ticked, then adjusting the original markdown based on positions.

Would be so awesome if this was completely standalone (with an optional markdown-it plugin) :smile: