fix(runner): support optional leading dashes in markdown checkboxes
This commit is contained in:
@@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user