From b16e82336a34743277c2b519dbb9d80fe5790f6d Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Tue, 3 Nov 2026 13:06:31 -0800 Subject: [PATCH 1/3] Add comprehensive README with usage instructions --- README.md | 89 +++++++++++++++++++------------------------------------ 1 file changed, 31 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index f2673b7..cf2b964 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,49 @@ # Logseq Task List Query Cleaner -A suite of Python scripts to clean up and normalize Logseq journal pages. +A Python script to clean up Logseq journal pages by removing the auto-generated "Task List" query blocks. -## Available Scripts +## Problem -### 1. `clean_task_lists.py` - Remove Task List Query Blocks -Removes auto-generated "Task List" query blocks that Logseq adds to journal pages. +Logseq journal pages often contain two auto-generated query blocks at the bottom: +1. **Work Task List** - Shows TODO/LATER items tagged with specific pages (e.g., `#neonai`) +2. **Personal Task List** - Shows TODO/LATER items not tagged with work pages +These query blocks add visual clutter when you want to review or archive daily notes. + +## Solution + +This script removes both Task List query blocks while preserving all your actual note content. + +## Usage + +### Basic Usage ```bash -python3 clean_task_lists.py --dry-run journals/ -python3 clean_task_lists.py -r journals/ -``` - -### 2. `clean_empty_bullets.py` - Remove Empty Bullet Lines -Removes empty bullet lines (lines with only whitespace and/or a single dash `-`). - -```bash -python3 clean_empty_bullets.py --dry-run journals/ -python3 clean_empty_bullets.py -r journals/ -``` - -### 3. `ensure_newline_ending.py` - Normalize File Endings -Ensures all files end with exactly one newline character. - -```bash -python3 ensure_newline_ending.py --dry-run journals/ -python3 ensure_newline_ending.py -r journals/ -``` - -### 4. `run_full_cleanup.sh` - Master Cleanup Script -Runs all cleanup scripts in the correct order: -1. Remove Task List query blocks (largest changes first) -2. Remove empty bullet lines (cleanup remnants) -3. Ensure single trailing newline (final normalization) - -```bash -# Dry run -./run_full_cleanup.sh --dry-run ~/notes_test/journals/ - # Process a single file -./run_full_cleanup.sh ~/notes_test/journals/JOURNAL_FILE.md +python3 clean_task_lists.py path/to/journal-page.md -# Process recursively -./run_full_cleanup.sh -r ~/notes_test/journals/ +# Process all .md files in a directory +python3 clean_task_lists.py path/to/journals/ + +# Process recursively through subdirectories +python3 clean_task_lists.py -r path/to/journals/ ``` -## Usage Examples - -### Quick Single File Cleanup +### Dry Run ```bash -# Use the master script for complete cleanup -./run_full_cleanup.sh path/to/journal.md +# See what would be changed without modifying files +python3 clean_task_lists.py --dry-run path/to/journals/ ``` -### Batch Process All Journals +### Examples ```bash -# Preview first -./run_full_cleanup.sh --dry-run -r journals/ +# Check a single file first +python3 clean_task_lists.py --dry-run 2026-10-23.md -# Then execute -./run_full_cleanup.sh -r journals/ -``` +# Clean a whole month of journals +python3 clean_task_lists.py journals/2026/10/ -### Individual Script Usage -```bash -# Just remove query blocks -python3 clean_task_lists.py -r journals/ - -# Just fix empty bullets -python3 clean_empty_bullets.py -r journals/ - -# Just normalize endings -python3 ensure_newline_ending.py -r journals/ +# Clean everything recursively +python3 clean_task_lists.py -r ~/logseq/journals/ ``` ## What Gets Removed @@ -88,6 +60,7 @@ And also handles variants with sorting options: - ## Daily Tasks - DONE Zyrtec :LOGBOOK: + CLOCK: [2026-10-23 Fri 17:22:24]--[2026-10-23 Fri 17:22:30] => 00:00:06 :END: - query-table:: true query-sort-by:: page From 75bc5543c8c8e04d87d1af816a60b87c0cb1679a Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Tue, 3 Nov 2026 14:01:04 -0800 Subject: [PATCH 2/3] Update README with all scripts and run_full_cleanup.sh documentation --- README.md | 88 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index cf2b964..c343b0b 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,77 @@ # Logseq Task List Query Cleaner -A Python script to clean up Logseq journal pages by removing the auto-generated "Task List" query blocks. +A suite of Python scripts to clean up and normalize Logseq journal pages. -## Problem +## Available Scripts -Logseq journal pages often contain two auto-generated query blocks at the bottom: -1. **Work Task List** - Shows TODO/LATER items tagged with specific pages (e.g., `#neonai`) -2. **Personal Task List** - Shows TODO/LATER items not tagged with work pages +### 1. `clean_task_lists.py` - Remove Task List Query Blocks +Removes auto-generated "Task List" query blocks that Logseq adds to journal pages. -These query blocks add visual clutter when you want to review or archive daily notes. - -## Solution - -This script removes both Task List query blocks while preserving all your actual note content. - -## Usage - -### Basic Usage ```bash +python3 clean_task_lists.py --dry-run journals/ +python3 clean_task_lists.py -r journals/ +``` + +### 2. `clean_empty_bullets.py` - Remove Empty Bullet Lines +Removes empty bullet lines (lines with only whitespace and/or a single dash `-`). + +```bash +python3 clean_empty_bullets.py --dry-run journals/ +python3 clean_empty_bullets.py -r journals/ +``` + +### 3. `ensure_newline_ending.py` - Normalize File Endings +Ensures all files end with exactly one newline character. + +```bash +python3 ensure_newline_ending.py --dry-run journals/ +python3 ensure_newline_ending.py -r journals/ +``` + +### 4. `run_full_cleanup.sh` - Master Cleanup Script +Runs all cleanup scripts in the correct order: +1. Remove Task List query blocks (largest changes first) +2. Remove empty bullet lines (cleanup remnants) +3. Ensure single trailing newline (final normalization) + +```bash +# Dry run +./run_full_cleanup.sh --dry-run ~/notes_test/journals/ + # Process a single file -python3 clean_task_lists.py path/to/journal-page.md +./run_full_cleanup.sh ~/notes_test/journals/2026_10_23.md -# Process all .md files in a directory -python3 clean_task_lists.py path/to/journals/ - -# Process recursively through subdirectories -python3 clean_task_lists.py -r path/to/journals/ +# Process recursively +./run_full_cleanup.sh -r ~/notes_test/journals/ ``` -### Dry Run +## Usage Examples + +### Quick Single File Cleanup ```bash -# See what would be changed without modifying files -python3 clean_task_lists.py --dry-run path/to/journals/ +# Use the master script for complete cleanup +./run_full_cleanup.sh path/to/journal.md ``` -### Examples +### Batch Process All Journals ```bash -# Check a single file first -python3 clean_task_lists.py --dry-run 2026-10-23.md +# Preview first +./run_full_cleanup.sh --dry-run -r journals/ -# Clean a whole month of journals -python3 clean_task_lists.py journals/2026/10/ +# Then execute +./run_full_cleanup.sh -r journals/ +``` -# Clean everything recursively -python3 clean_task_lists.py -r ~/logseq/journals/ +### Individual Script Usage +```bash +# Just remove query blocks +python3 clean_task_lists.py -r journals/ + +# Just fix empty bullets +python3 clean_empty_bullets.py -r journals/ + +# Just normalize endings +python3 ensure_newline_ending.py -r journals/ ``` ## What Gets Removed From bdb81cfeb225359598606361d483b43032a5c2de Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Tue, 3 Nov 2026 20:36:09 -0800 Subject: [PATCH 3/3] Fix: Catch query blocks with no prefix (just whitespace before #+BEGIN_QUERY) --- clean_task_lists.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clean_task_lists.py b/clean_task_lists.py index eb243cb..8797bcd 100755 --- a/clean_task_lists.py +++ b/clean_task_lists.py @@ -16,9 +16,11 @@ def remove_task_list_queries(content: str) -> Tuple[str, int]: 1. - query-table:: + collapsed:: (no dash) + #+BEGIN_QUERY 2. collapsed:: (no dash) + - query-table:: + #+BEGIN_QUERY 3. - collapsed:: + #+BEGIN_QUERY - 4. - #+BEGIN_QUERY (direct, no prefix) + 4. - #+BEGIN_QUERY (direct with dash) + 5. #+BEGIN_QUERY (no dash, no prefix - just whitespace) """ - pattern = r'(?:- query-table::\s*(?:true|false)\s*\n\s+collapsed::\s*true\s*\n\s*#\+BEGIN_QUERY|collapsed::\s*true\s*\n\s*- query-table::\s*(?:true|false)\s*\n\s*#\+BEGIN_QUERY|- collapsed::\s*true\s*\n\s*#\+BEGIN_QUERY|- #\+BEGIN_QUERY)[\s\S]*?:title\s*"[✅✓]?\s*(?:Task|ToDo)\s*List"[\s\S]*?#\+END_QUERY' + # Pattern handles all 5 formats above + pattern = r'(?:- query-table::\s*(?:true|false)\s*\n\s+collapsed::\s*true\s*\n\s*#\+BEGIN_QUERY|collapsed::\s*true\s*\n\s*- query-table::\s*(?:true|false)\s*\n\s*#\+BEGIN_QUERY|- collapsed::\s*true\s*\n\s*#\+BEGIN_QUERY|- #\+BEGIN_QUERY|\s*#\+BEGIN_QUERY)[\s\S]*?:title\s*"[✅✓]?\s*(?:Task|ToDo)\s*List"[\s\S]*?#\+END_QUERY' matches = re.findall(pattern, content) count = len(matches)