forked from kenkeiras/org-rw
format: Apply black formatter.
This commit is contained in:
parent
527a9e7eb2
commit
14e344981b
@ -67,7 +67,9 @@ BASE_ENVIRONMENT = {
|
||||
),
|
||||
}
|
||||
|
||||
HEADLINE_TAGS_RE = re.compile(r"((?P<space_before_tags>\s+)(:(\w|[0-9_@#%])+)+:)(?P<space_after_tags>\s*)$")
|
||||
HEADLINE_TAGS_RE = re.compile(
|
||||
r"((?P<space_before_tags>\s+)(:(\w|[0-9_@#%])+)+:)(?P<space_after_tags>\s*)$"
|
||||
)
|
||||
HEADLINE_RE = re.compile(r"^(?P<stars>\*+)(?P<spacing>\s+)(?P<line>.*?)$")
|
||||
KEYWORDS_RE = re.compile(
|
||||
r"^(?P<indentation>\s*)#\+(?P<key>[^:\[]+)(\[(?P<options>[^\]]*)\])?:(?P<spacing>\s*)(?P<value>.*)$"
|
||||
@ -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,7 +2214,7 @@ 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)]
|
||||
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user