- Replace pattern.sub() with str.replace() for more reliable matching
- Add newline preservation to maintain proper spacing after removal
- Clean up trailing whitespace on all lines
- Normalize file ending with single trailing newline
- Handle all three formats: query-table prefix, collapsed prefix, and standalone
This version has been tested and successfully removes all Task List query blocks
while preserving non-Task-List queries and maintaining proper file formatting.
- Use single pattern matching #+BEGIN_QUERY to #+END_QUERY
- Check for Task/ToDo List title within the block
- Catches all formats without enumerating prefixes