fix: strip token_list_to_plaintext
otherwise when you do headline.title.get_text() you may have trailing whitespaces
This commit is contained in:
parent
8280949f23
commit
6710775882
@ -415,7 +415,6 @@ class Headline:
|
|||||||
isinstance(line, DelimiterLine)
|
isinstance(line, DelimiterLine)
|
||||||
and line.delimiter_type == DelimiterLineType.END_BLOCK
|
and line.delimiter_type == DelimiterLineType.END_BLOCK
|
||||||
):
|
):
|
||||||
|
|
||||||
start = current_node.header.linenum
|
start = current_node.header.linenum
|
||||||
end = line.linenum
|
end = line.linenum
|
||||||
|
|
||||||
@ -815,7 +814,6 @@ class Headline:
|
|||||||
|
|
||||||
def set_property(self, name: str, value: str):
|
def set_property(self, name: str, value: str):
|
||||||
for prop in self.properties:
|
for prop in self.properties:
|
||||||
|
|
||||||
# A matching property is found, update it
|
# A matching property is found, update it
|
||||||
if prop.key == name:
|
if prop.key == name:
|
||||||
prop.value = value
|
prop.value = value
|
||||||
@ -1000,7 +998,6 @@ class Headline:
|
|||||||
and result_first[0] == "structural"
|
and result_first[0] == "structural"
|
||||||
and result_first[1].strip().upper() == ":RESULTS:"
|
and result_first[1].strip().upper() == ":RESULTS:"
|
||||||
):
|
):
|
||||||
|
|
||||||
(end_line, _) = self.get_structural_end_after(
|
(end_line, _) = self.get_structural_end_after(
|
||||||
kword.linenum + 1
|
kword.linenum + 1
|
||||||
)
|
)
|
||||||
@ -1795,7 +1792,7 @@ def token_list_to_plaintext(tok_list) -> str:
|
|||||||
else:
|
else:
|
||||||
assert isinstance(chunk, MarkerToken)
|
assert isinstance(chunk, MarkerToken)
|
||||||
|
|
||||||
return "".join(contents)
|
return "".join(contents).strip()
|
||||||
|
|
||||||
|
|
||||||
def token_list_to_raw(tok_list):
|
def token_list_to_raw(tok_list):
|
||||||
@ -2017,7 +2014,6 @@ def tokenize_contents(contents: str) -> List[TokenItems]:
|
|||||||
and is_pre(last_char)
|
and is_pre(last_char)
|
||||||
and ((i + 1 < len(contents)) and is_border(contents[i + 1]))
|
and ((i + 1 < len(contents)) and is_border(contents[i + 1]))
|
||||||
):
|
):
|
||||||
|
|
||||||
is_valid_mark = False
|
is_valid_mark = False
|
||||||
# Check that is closed later
|
# Check that is closed later
|
||||||
text_in_line = True
|
text_in_line = True
|
||||||
@ -2408,7 +2404,6 @@ class OrgDoc:
|
|||||||
|
|
||||||
# Writing
|
# Writing
|
||||||
def dump_headline(self, headline, recursive=True):
|
def dump_headline(self, headline, recursive=True):
|
||||||
|
|
||||||
tags = ""
|
tags = ""
|
||||||
if len(headline.shallow_tags) > 0:
|
if len(headline.shallow_tags) > 0:
|
||||||
tags = ":" + ":".join(headline.shallow_tags) + ":"
|
tags = ":" + ":".join(headline.shallow_tags) + ":"
|
||||||
@ -2422,7 +2417,14 @@ class OrgDoc:
|
|||||||
if not (raw_title.endswith(" ") or raw_title.endswith("\t")) and tags:
|
if not (raw_title.endswith(" ") or raw_title.endswith("\t")) and tags:
|
||||||
tags_padding = " "
|
tags_padding = " "
|
||||||
|
|
||||||
yield "*" * headline.depth + headline.spacing + state + raw_title + tags_padding + tags
|
yield (
|
||||||
|
"*" * headline.depth
|
||||||
|
+ headline.spacing
|
||||||
|
+ state
|
||||||
|
+ raw_title
|
||||||
|
+ tags_padding
|
||||||
|
+ tags
|
||||||
|
)
|
||||||
|
|
||||||
planning = headline.get_planning_line()
|
planning = headline.get_planning_line()
|
||||||
if planning is not None:
|
if planning is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user