This commit is contained in:
Ian Gulliver
2026-10-16 13:03:22 -07:00
parent d9e0498d10
commit 5b22e5bc70
6 changed files with 49 additions and 3 deletions
+7
View File
@@ -12,6 +12,7 @@ const bullet = /^(\s*)[-*+]\s+(.*)$/;
const ordered = /^(\s*)(\d+)[.)]\s+(.*)$/;
const quote = /^\s*>\s?(.*)$/;
const rule = /^\s*([-*_])(\s*\1){2,}\s*$/;
const imageOnly = /^\s*!\[[^\]]*\]\((<[^>]*>|[^)]*)\)\s*$/;
const tableSep = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;
export function markdown(src, className = "md", opts = {}) {
return h("div", { class: className }, ...blocks(src.replace(/\r\n?/g, "\n").split("\n"), opts));
@@ -165,6 +166,7 @@ function parseList(lines, start, opts) {
}
}
let i = start;
let imageChoices = !isOrdered && !!opts.choice;
while (i < lines.length) {
const line = lines[i];
const m = isOrdered ? ordered.exec(line) : bullet.exec(line);
@@ -191,11 +193,16 @@ function parseList(lines, start, opts) {
body.push(indentOf(next) > base ? next.slice(Math.min(indentOf(next), base + 2)) : next.trim());
i++;
}
const detail = body.slice(1).filter((l) => l.trim() !== "");
imageChoices &&= choiceMarker.test(text) && detail.length === 1 && imageOnly.test(detail[0]);
list.append(item(body, isOrdered ? { taskId: opts.taskId } : opts));
while (i < lines.length && lines[i].trim() === "" && lines[i + 1] !== undefined && indentOf(lines[i + 1]) === base && (isOrdered ? ordered : bullet).test(lines[i + 1])) {
i++;
}
}
if (imageChoices) {
list.className = "choice-grid";
}
return [list, i];
}
function item(body, opts) {
+1 -1
View File
File diff suppressed because one or more lines are too long