UNPKG

laif-ds

Version:

Design System di Laif con componenti React basati su principi di Atomic Design

60 lines (59 loc) 1.8 kB
"use client"; import { ok as l } from "../../devlop/lib/default.js"; import { handle as f } from "../../mdast-util-to-markdown/lib/handle/index.js"; function y() { return { exit: { taskListCheckValueChecked: h, taskListCheckValueUnchecked: h, paragraph: u } }; } function b() { return { unsafe: [{ atBreak: !0, character: "-", after: "[:|-]" }], handlers: { listItem: m } }; } function h(s) { const e = this.stack[this.stack.length - 2]; l(e.type === "listItem"), e.checked = s.type === "taskListCheckValueChecked"; } function u(s) { const e = this.stack[this.stack.length - 2]; if (e && e.type === "listItem" && typeof e.checked == "boolean") { const i = this.stack[this.stack.length - 1]; l(i.type === "paragraph"); const t = i.children[0]; if (t && t.type === "text") { const a = e.children; let c = -1, n; for (; ++c < a.length; ) { const r = a[c]; if (r.type === "paragraph") { n = r; break; } } n === i && (t.value = t.value.slice(1), t.value.length === 0 ? i.children.shift() : i.position && t.position && typeof t.position.start.offset == "number" && (t.position.start.column++, t.position.start.offset++, i.position.start = Object.assign({}, t.position.start))); } } this.exit(s); } function m(s, e, i, t) { const a = s.children[0], c = typeof s.checked == "boolean" && a && a.type === "paragraph", n = "[" + (s.checked ? "x" : " ") + "] ", r = i.createTracker(t); c && r.move(n); let o = f.listItem(s, e, i, { ...t, ...r.current() }); return c && (o = o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, k)), o; function k(p) { return p + n; } } export { y as gfmTaskListItemFromMarkdown, b as gfmTaskListItemToMarkdown };