Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(web): ignore invalid checklist closing fences

Tinab6d2b519762
diff --git a/apps/web/src/lib/get-task-item-stats.test.ts b/apps/web/src/lib/get-task-item-stats.test.ts
index 6e5fc52e7..1a49817cf 100644
--- a/apps/web/src/lib/get-task-item-stats.test.ts
+++ b/apps/web/src/lib/get-task-item-stats.test.ts
@@ -41,4 +41,15 @@ describe("getTaskItemStats", () => {
completed: 1,
});
});
+
+ it.each(["```", "~~~"])(
+ "keeps a %s fence open when a marker has trailing content",
+ (marker) => {
+ const description = `${marker}\n${marker}ts\n- [x] Example\n${marker} \t\n- [ ] Real item`;
+
+ const stats = getTaskItemStats(description);
+
+ expect(stats).toEqual({ total: 1, completed: 0 });
+ },
+ );
});
diff --git a/apps/web/src/lib/get-task-item-stats.ts b/apps/web/src/lib/get-task-item-stats.ts
index 317359c41..94cfde793 100644
--- a/apps/web/src/lib/get-task-item-stats.ts
+++ b/apps/web/src/lib/get-task-item-stats.ts
@@ -38,7 +38,11 @@ export function getTaskItemStats(description: string | null): TaskItemsStats {
// Opening a new fence
fenceChar = marker[0];
fenceLen = marker.length;
- } else if (marker[0] === fenceChar && marker.length >= fenceLen) {
+ } else if (
+ marker[0] === fenceChar &&
+ marker.length >= fenceLen &&
+ /^[\t ]*$/.test(line.slice(fenceMatch[0].length))
+ ) {
// Closing the current fence
fenceChar = null;
}