From 90113adbe8c4146aca792c39d3269004fc7f6c4d Mon Sep 17 00:00:00 2001 From: Hoang Nam Date: Mon, 9 Feb 2026 15:57:45 +0700 Subject: [PATCH] fix: Exclude code blocks from task counting in the progress bar view and update the plugin version to 1.5.2. --- manifest.json | 4 ++-- package.json | 11 ++++++++--- src/views/ProgressBarView.ts | 12 ++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/manifest.json b/manifest.json index a8262f1..1d1e8f3 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "id": "progress-tracker", "name": "ProgressTracker", - "version": "1.5.1", + "version": "1.5.2", "minAppVersion": "1.1.0", "description": "Track task completion with a visual progress bar in your sidebar, auto update column Kanban", "author": "VN", "authorUrl": "https://github.com/vannamhh/", "isDesktopOnly": false -} +} \ No newline at end of file diff --git a/package.json b/package.json index 16931dc..e1a3208 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "progress-tracker", - "version": "1.5.1", + "version": "1.5.2", "description": "Track task completion with a visual progress bar in your sidebar", "main": "main.js", "scripts": { @@ -8,7 +8,12 @@ "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", "version": "node version-bump.mjs && git add manifest.json versions.json" }, - "keywords": ["obsidian", "dataview", "progress", "task"], + "keywords": [ + "obsidian", + "dataview", + "progress", + "task" + ], "author": "VN", "license": "MIT", "devDependencies": { @@ -21,4 +26,4 @@ "tslib": "2.4.0", "typescript": "4.7.4" } -} +} \ No newline at end of file diff --git a/src/views/ProgressBarView.ts b/src/views/ProgressBarView.ts index fcdf0af..9d42054 100644 --- a/src/views/ProgressBarView.ts +++ b/src/views/ProgressBarView.ts @@ -277,8 +277,10 @@ export class TaskProgressBarView extends ItemView { ); } else { // Legacy counting - only [ ] and [x] - incompleteTasks = (content.match(/- \[ \]/g) || []).length; - completedTasks = (content.match(/- \[x\]/gi) || []).length; + // Remove code blocks before counting to avoid counting tasks inside code blocks + const contentWithoutCodeBlocks = removeCodeBlocks(content); + incompleteTasks = (contentWithoutCodeBlocks.match(/- \[ \]/g) || []).length; + completedTasks = (contentWithoutCodeBlocks.match(/- \[x\]/gi) || []).length; } let totalTasks = incompleteTasks + completedTasks + customStateTasks; @@ -287,8 +289,10 @@ export class TaskProgressBarView extends ItemView { let relaxedIncompleteTasks = 0; let relaxedCompletedTasks = 0; if (totalTasks === 0) { - relaxedIncompleteTasks = (content.match(/[-*] \[ \]/g) || []).length; - relaxedCompletedTasks = (content.match(/[-*] \[x\]/gi) || []).length; + // Also remove code blocks when using relaxed regex + const contentWithoutCodeBlocks = removeCodeBlocks(content); + relaxedIncompleteTasks = (contentWithoutCodeBlocks.match(/[-*] \[ \]/g) || []).length; + relaxedCompletedTasks = (contentWithoutCodeBlocks.match(/[-*] \[x\]/gi) || []).length; totalTasks = relaxedIncompleteTasks + relaxedCompletedTasks; }