Fix headline dumping after tags and state where separated.

This commit is contained in:
Sergio Martínez Portela 2021-01-05 00:24:33 +01:00
parent e1f22d360c
commit 09f2aed8fe

View File

@ -43,7 +43,7 @@ BASE_ENVIRONMENT = {
), ),
} }
HEADLINE_TAGS_RE = re.compile(r"((:[a-zA-Z0-9_@#%]+)+:)") HEADLINE_TAGS_RE = re.compile(r"((:[a-zA-Z0-9_@#%]+)+:)\s*$")
HEADLINE_RE = re.compile(r"^(?P<stars>\*+) (?P<spacing>\s*)(?P<line>.*?)$") HEADLINE_RE = re.compile(r"^(?P<stars>\*+) (?P<spacing>\s*)(?P<line>.*?)$")
KEYWORDS_RE = re.compile( KEYWORDS_RE = re.compile(
r"^(?P<indentation>\s*)#\+(?P<key>[^:\[]+)(\[(?P<options>[^\]]*)\])?:(?P<spacing>\s*)(?P<value>.*)$" r"^(?P<indentation>\s*)#\+(?P<key>[^:\[]+)(\[(?P<options>[^\]]*)\])?:(?P<spacing>\s*)(?P<value>.*)$"
@ -890,14 +890,14 @@ def parse_headline(hl, doc, parent) -> Headline:
hl_state = None hl_state = None
title = line title = line
is_done = is_todo = False is_done = is_todo = False
for state in doc.todo_keywords: for state in doc.todo_keywords or []:
if title.startswith(state + " "): if title.startswith(state + " "):
hl_state = state hl_state = state
title = title[len(state + " ") :] title = title[len(state + " ") :]
is_todo = True is_todo = True
break break
else: else:
for state in doc.done_keywords: for state in doc.done_keywords or []:
if title.startswith(state + " "): if title.startswith(state + " "):
hl_state = state hl_state = state
title = title[len(state + " ") :] title = title[len(state + " ") :]
@ -1022,9 +1022,18 @@ class OrgDoc:
return (line.linenum, line.line) return (line.linenum, line.line)
def dump_headline(self, headline): def dump_headline(self, headline):
yield "*" * headline.depth + " " + headline.orig.group(
tags = ""
if len(headline.shallow_tags) > 0:
tags = ":" + ":".join(headline.shallow_tags) + ":"
state = ""
if headline.state:
state = headline.state + " "
yield "*" * headline.depth + " " + state + headline.orig.group(
"spacing" "spacing"
) + headline.title ) + headline.title + tags
lines = [] lines = []
KW_T = 0 KW_T = 0