From c6bed839e8465984870cfddc98f42159c29f57b7 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Tue, 3 Nov 2026 16:56:48 -0800 Subject: [PATCH] Fix pattern to handle ToDo List and multi-line query blocks --- clean_task_lists.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/clean_task_lists.py b/clean_task_lists.py index 33503f9..52c8c43 100644 --- a/clean_task_lists.py +++ b/clean_task_lists.py @@ -8,7 +8,7 @@ Most days have two such blocks: 2. Personal Task List (non-work tasks) The query blocks are marked with #+BEGIN_QUERY ... #+END_QUERY and contain -"title "✅ Task List"" in their configuration. +"title "✅ Task List"" or "title "✅ ToDo List"" in their configuration. """ import re @@ -28,13 +28,11 @@ def remove_task_list_queries(content: str) -> Tuple[str, int]: Tuple of (cleaned content, number of blocks removed) """ # Pattern to match query-table lines and #+BEGIN_QUERY ... #+END_QUERY blocks - # that contain Task List. The query blocks in Logseq may have: + # that contain Task List or ToDo List. Handles: # - query-table:: true/false - # - Optional query-sort-by:: and query-sort-desc:: lines (lines starting with - # whitespace and containing "query-" prefix) - # - #+BEGIN_QUERY ... #+END_QUERY - # Note: # must be escaped as \# in regex - pattern = r'query-table:: (?:true|false)(?:\s*\n\s+query-.*?:: .*?)*\s*\n\s*\#\+BEGIN_QUERY.*?:title "✅ Task List".*?\#\+END_QUERY' + # - Optional collapsed::, query-sort-* lines + # - Multi-line or single-line #+BEGIN_QUERY ... #+END_QUERY + pattern = r'query-table::\s*(?:true|false).*?#\+BEGIN_QUERY.*?:title\s*"[✅✓]?\s*(?:Task|ToDo)\s*List".*?#\+END_QUERY' # Find all matches first to count them matches = re.findall(pattern, content, re.DOTALL) @@ -112,7 +110,7 @@ def main(): dry_run = args.dry_run # Collect files to process - files: List[Path] = [] + files = [] if target.is_file(): if target.suffix.lower() not in ['.md', '.markdown']: @@ -151,4 +149,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main()