Fix OrgNode render of entries with property drawers and empty body

- Issue
  - Indent regex was previously catching escape sequences like newlines
  - This was resulting in entries with only escape sequences in body to
    be prepended to property drawers etc during rendering
- Fix
  - Update indent regex to only look for spaces in each line
  - Only render body when body contains non-escape characters
  - Create test to prevent this regression from silently resurfacing
This commit is contained in:
Debanjum Singh Solanky
2022-09-11 15:54:26 +03:00
parent 253c9eae9a
commit 9d369ae4df
2 changed files with 32 additions and 4 deletions

View File

@@ -38,7 +38,7 @@ import datetime
from pathlib import Path
from os.path import relpath
indent_regex = re.compile(r'^\s*')
indent_regex = re.compile(r'^ *')
def normalize_filename(filename):
"Normalize and escape filename for rendering"
@@ -455,6 +455,8 @@ class Orgnode(object):
n = n + indent + f":{key}: {value}\n"
n = n + indent + ":END:\n"
n = n + self._body
# Output Body
if self.hasBody:
n = n + self._body
return n