Refactor Logseq scripts to their own directory

This commit is contained in:
Daniel McKnight 2026-11-12 16:55:28 -08:00
parent 3b95671fb8
commit a0b42920d9
6 changed files with 0 additions and 0 deletions

157
logseq_cleanup/README.md Normal file
View file

@ -0,0 +1,157 @@
# Logseq Task List Query Cleaner
A suite of Python scripts to clean up and normalize Logseq journal pages.
## Available Scripts
### 1. `clean_task_lists.py` - Remove Task List Query Blocks
Removes auto-generated "Task List" query blocks that Logseq adds to journal pages.
```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
# Process recursively
./run_full_cleanup.sh -r ~/notes_test/journals/
```
## Usage Examples
### Quick Single File Cleanup
```bash
# Use the master script for complete cleanup
./run_full_cleanup.sh path/to/journal.md
```
### Batch Process All Journals
```bash
# Preview first
./run_full_cleanup.sh --dry-run -r journals/
# Then execute
./run_full_cleanup.sh -r 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
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:
: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.