Files
sgauthier 6e64e138e2
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
planning
2024-10-14 09:15:30 +02:00

23 lines
604 B
JavaScript

var defaultListItem = require('mdast-util-to-markdown/lib/handle/list-item')
exports.unsafe = [{atBreak: true, character: '-', after: '[:|-]'}]
exports.handlers = {
listItem: listItemWithTaskListItem
}
function listItemWithTaskListItem(node, parent, context) {
var value = defaultListItem(node, parent, context)
var head = node.children[0]
if (typeof node.checked === 'boolean' && head && head.type === 'paragraph') {
value = value.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, check)
}
return value
function check($0) {
return $0 + '[' + (node.checked ? 'x' : ' ') + '] '
}
}