fix(runner): support optional leading dashes in markdown checkboxes

This commit is contained in:
2026-06-03 14:56:40 -07:00
parent 71bea9103f
commit 4f9c82b525
2 changed files with 12 additions and 6 deletions

View File

@@ -224,7 +224,7 @@ function parseTaskItems(repoRoot) {
const content = fs.readFileSync(filePath, "utf8"); const content = fs.readFileSync(filePath, "utf8");
const lines = content.split("\n"); const lines = content.split("\n");
lines.forEach((line, lineIndex) => { lines.forEach((line, lineIndex) => {
const match = line.match(/^(\s*)-\s*\[([ xX])\]\s+(.+)$/); const match = line.match(/^(\s*)(?:-\s*)?\[([ xX])\]\s+(.+)$/);
if (match && match[2] !== undefined && match[3] !== undefined) { if (match && match[2] !== undefined && match[3] !== undefined) {
items.push({ items.push({
text: match[3].trim(), text: match[3].trim(),
@@ -248,9 +248,12 @@ function toggleTaskOnDisk(task) {
const lines = content.split("\n"); const lines = content.split("\n");
const line = lines[task.lineIndex]; const line = lines[task.lineIndex];
if (line) { if (line) {
const match = line.match(/^(\s*)-\s*\[([ xX])\]\s+(.+)$/); const match = line.match(/^(\s*)(?:-\s*)?\[([ xX])\]\s+(.+)$/);
if (match && match[1] !== undefined && match[3] !== undefined) { if (match && match[1] !== undefined && match[3] !== undefined) {
lines[task.lineIndex] = `${match[1]}- [x] ${match[3]}`; const indent = match[1] || "";
const hasDash = line.includes("-");
const prefix = hasDash ? `${indent}- ` : indent;
lines[task.lineIndex] = `${prefix}[x] ${match[3]}`;
fs.writeFileSync(task.filePath, lines.join("\n"), "utf8"); fs.writeFileSync(task.filePath, lines.join("\n"), "utf8");
} }
} }

View File

@@ -316,7 +316,7 @@ function parseTaskItems(repoRoot: string): TaskItem[] {
const content = fs.readFileSync(filePath, "utf8"); const content = fs.readFileSync(filePath, "utf8");
const lines = content.split("\n"); const lines = content.split("\n");
lines.forEach((line: string, lineIndex: number) => { lines.forEach((line: string, lineIndex: number) => {
const match = line.match(/^(\s*)-\s*\[([ xX])\]\s+(.+)$/); const match = line.match(/^(\s*)(?:-\s*)?\[([ xX])\]\s+(.+)$/);
if (match && match[2] !== undefined && match[3] !== undefined) { if (match && match[2] !== undefined && match[3] !== undefined) {
items.push({ items.push({
text: match[3].trim(), text: match[3].trim(),
@@ -340,9 +340,12 @@ function toggleTaskOnDisk(task: TaskItem): void {
const lines = content.split("\n"); const lines = content.split("\n");
const line = lines[task.lineIndex]; const line = lines[task.lineIndex];
if (line) { if (line) {
const match = line.match(/^(\s*)-\s*\[([ xX])\]\s+(.+)$/); const match = line.match(/^(\s*)(?:-\s*)?\[([ xX])\]\s+(.+)$/);
if (match && match[1] !== undefined && match[3] !== undefined) { if (match && match[1] !== undefined && match[3] !== undefined) {
lines[task.lineIndex] = `${match[1]}- [x] ${match[3]}`; const indent = match[1] || "";
const hasDash = line.includes("-");
const prefix = hasDash ? `${indent}- ` : indent;
lines[task.lineIndex] = `${prefix}[x] ${match[3]}`;
fs.writeFileSync(task.filePath, lines.join("\n"), "utf8"); fs.writeFileSync(task.filePath, lines.join("\n"), "utf8");
} }
} }