jaywcjlove/html-to-markdown-cli

Format not well when convert checked list

thunderfalco opened this issue · 3 comments

origin html:

<ul data-type="taskList">
    <li data-checked="false" data-type="taskItem">
        <label>
            <input type="checkbox">
            <span></span>
       </label>
       <div><p>question</p></div>
    </li>
</ul>

result:
image

image
  • [ ]

    question

@thunderfalco This requires adding rehypePlugins/remarkPlugins separately, as this is not standard checked list HTML.

<ul>
 <li><input type="checkbox"> question</li>
</ul>

@thunderfalco

if (node.type === "element" && node.tagName === "li") {
let code = getCodeString(node.children)
node.children = [
{
type: "element",
tagName: "input",
properties: {
type: "checkbox",
checked: false
}
},
{
type: "text",
value: code
}
]
}