130 lines
No EOL
3.2 KiB
Markdown
130 lines
No EOL
3.2 KiB
Markdown
# Logseq Task List Query Cleaner
|
|
|
|
A Python script to clean up Logseq journal pages by removing the auto-generated "Task List" query blocks.
|
|
|
|
## Problem
|
|
|
|
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
|
|
# Process a single file
|
|
python3 clean_task_lists.py path/to/journal-page.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/
|
|
```
|
|
|
|
### Dry Run
|
|
```bash
|
|
# See what would be changed without modifying files
|
|
python3 clean_task_lists.py --dry-run path/to/journals/
|
|
```
|
|
|
|
### Examples
|
|
```bash
|
|
# Check a single file first
|
|
python3 clean_task_lists.py --dry-run 2026-10-23.md
|
|
|
|
# Clean a whole month of journals
|
|
python3 clean_task_lists.py journals/2026/10/
|
|
|
|
# Clean everything recursively
|
|
python3 clean_task_lists.py -r ~/logseq/journals/
|
|
```
|
|
|
|
## What Gets Removed
|
|
|
|
The script removes blocks like:
|
|
```markdown
|
|
- - query-table:: false
|
|
#+BEGIN_QUERY {:title "✅ Task List" :query [:find (pull ?h [*]) :where ... ] :group-by-page? false :collapsed? false}
|
|
#+END_QUERY
|
|
```
|
|
|
|
And also handles variants with sorting options:
|
|
```markdown
|
|
- ## 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
|
|
query-sort-desc:: false
|
|
#+BEGIN_QUERY {:title "✅ Task List" :query [:find (pull ?h [*]) :where ... ] :group-by-page? false :collapsed? false}
|
|
#+END_QUERY
|
|
```
|
|
|
|
## What Gets Preserved
|
|
|
|
✅ All meeting notes
|
|
✅ All task descriptions and progress
|
|
✅ All CLOCK entries and time tracking
|
|
✅ All tags and links
|
|
✅ All bullet points and nested content
|
|
✅ All other query blocks (non-Task-List)
|
|
|
|
## Safety Features
|
|
|
|
- **Dry run mode** - See what would change before making modifications
|
|
- **Batch processing** - Handle entire directories of journals
|
|
- **Pattern-specific** - Only removes blocks with "✅ Task List" title
|
|
- **Non-destructive** - All actual content is preserved
|
|
|
|
## Requirements
|
|
|
|
- Python 3.6+
|
|
- No external dependencies (uses only stdlib `re`, `argparse`, `pathlib`)
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
# Clone the repository
|
|
git clone <repo-url> logseq-cleanup
|
|
cd logseq-cleanup
|
|
|
|
# Make executable (optional)
|
|
chmod +x clean_task_lists.py
|
|
|
|
# Create a symlink for easy access
|
|
ln -s $(pwd)/clean_task_lists.py ~/bin/logseq-clean
|
|
```
|
|
|
|
Then use:
|
|
```bash
|
|
logseq-clean --dry-run ~/logseq/journals/
|
|
```
|
|
|
|
## Testing
|
|
|
|
A test file (`test_input.md`) is included with sample Logseq content. To test:
|
|
|
|
```bash
|
|
# Dry run on test file
|
|
python3 clean_task_lists.py --dry-run test_input.md
|
|
|
|
# Actually process test file
|
|
cp test_input.md test_output.md
|
|
python3 clean_task_lists.py test_output.md
|
|
|
|
# Compare
|
|
diff test_input.md test_output.md
|
|
```
|
|
|
|
## License
|
|
|
|
MIT License - Feel free to modify for your own Logseq setup. |