diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index 5c00e75..fdbd177 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -67,7 +67,9 @@ BASE_ENVIRONMENT = { ), } -HEADLINE_TAGS_RE = re.compile(r"((?P\s+)(:(\w|[0-9_@#%])+)+:)(?P\s*)$") +HEADLINE_TAGS_RE = re.compile( + r"((?P\s+)(:(\w|[0-9_@#%])+)+:)(?P\s*)$" +) HEADLINE_RE = re.compile(r"^(?P\*+)(?P\s+)(?P.*?)$") KEYWORDS_RE = re.compile( r"^(?P\s*)#\+(?P[^:\[]+)(\[(?P[^\]]*)\])?:(?P\s*)(?P.*)$" @@ -2186,11 +2188,11 @@ def parse_headline(hl, doc, parent) -> Headline: if hl_tags is None: tags = [] - space_before_tags = space_after_tags = '' + space_before_tags = space_after_tags = "" else: tags = hl_tags.group(0).strip()[1:-1].split(":") - space_before_tags = hl_tags.group('space_before_tags') or '' - space_after_tags = hl_tags.group('space_after_tags') or '' + space_before_tags = hl_tags.group("space_before_tags") or "" + space_after_tags = hl_tags.group("space_after_tags") or "" line = HEADLINE_TAGS_RE.sub("", line) hl_state = None @@ -2212,10 +2214,10 @@ def parse_headline(hl, doc, parent) -> Headline: if len(tags) == 0: # No tags, so title might contain trailing whitespaces, handle it - title_ends_with_whitespace_match = re.search(r'\s+$', title) + title_ends_with_whitespace_match = re.search(r"\s+$", title) if title_ends_with_whitespace_match is not None: space_before_tags = title_ends_with_whitespace_match.group(0) - title = title[:-len(space_before_tags)] + title = title[: -len(space_before_tags)] contents = parse_contents(hl["contents"]) @@ -2448,7 +2450,9 @@ class OrgDoc: def dump_headline(self, headline, recursive=True): tags = headline.space_before_tags if len(headline.shallow_tags) > 0: - tags += ":" + ":".join(headline.shallow_tags) + ":" + headline.space_after_tags + tags += ( + ":" + ":".join(headline.shallow_tags) + ":" + headline.space_after_tags + ) state = "" if headline._state: @@ -2456,13 +2460,7 @@ class OrgDoc: raw_title = token_list_to_raw(headline.title.contents) - yield ( - "*" * headline.depth - + headline.spacing - + state - + raw_title - + tags - ) + yield ("*" * headline.depth + headline.spacing + state + raw_title + tags) planning = headline.get_planning_line() if planning is not None: