Fix Headlines with properties but no content lines.
This commit is contained in:
parent
ffe6f007fc
commit
7f67c768c6
@ -684,8 +684,6 @@ def parse_contents(raw_contents: List[RawLine]):
|
|||||||
current_line = line.linenum
|
current_line = line.linenum
|
||||||
current_block.append(line)
|
current_block.append(line)
|
||||||
else:
|
else:
|
||||||
# Mark the finishing block as not the last line
|
|
||||||
current_block.append(RawLine(current_line + 1, ""))
|
|
||||||
# Split the blocks
|
# Split the blocks
|
||||||
blocks.append(current_block)
|
blocks.append(current_block)
|
||||||
current_line = line.linenum
|
current_line = line.linenum
|
||||||
@ -884,14 +882,17 @@ class OrgDom:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
elif ltype != CONTENT_T:
|
content = content + "\n"
|
||||||
content = content + "\n"
|
|
||||||
|
|
||||||
last_type = ltype
|
last_type = ltype
|
||||||
structured_lines.append(content)
|
structured_lines.append(content)
|
||||||
|
|
||||||
if len(structured_lines) > 0:
|
if len(structured_lines) > 0:
|
||||||
yield "".join(structured_lines)
|
content = "".join(structured_lines)
|
||||||
|
|
||||||
|
# Remove the last line jump, which will be accounted for by the "yield operation"
|
||||||
|
assert content.endswith("\n")
|
||||||
|
content = content[:-1]
|
||||||
|
yield content
|
||||||
|
|
||||||
for child in headline.children:
|
for child in headline.children:
|
||||||
yield from self.dump_headline(child)
|
yield from self.dump_headline(child)
|
||||||
@ -1075,7 +1076,7 @@ def loads(s, environment=BASE_ENVIRONMENT, extra_cautious=True):
|
|||||||
sys.stderr.writelines(diff)
|
sys.stderr.writelines(diff)
|
||||||
# print("---\n" + after_dump + "\n---")
|
# print("---\n" + after_dump + "\n---")
|
||||||
|
|
||||||
raise Exception("Difference found between existing version and dumped one")
|
raise Exception("Difference found between existing version and dumped")
|
||||||
return dom
|
return dom
|
||||||
|
|
||||||
|
|
||||||
@ -1086,5 +1087,5 @@ def load(f, environment=BASE_ENVIRONMENT, extra_cautious=False):
|
|||||||
def dumps(doc):
|
def dumps(doc):
|
||||||
dump = list(doc.dump())
|
dump = list(doc.dump())
|
||||||
result = "\n".join(dump)
|
result = "\n".join(dump)
|
||||||
print(result)
|
# print(result)
|
||||||
return result
|
return result
|
||||||
|
@ -22,3 +22,9 @@ Second level content with no indentation or space around
|
|||||||
:END:
|
:END:
|
||||||
|
|
||||||
Forth level content
|
Forth level content
|
||||||
|
|
||||||
|
***** Fifth level with properties but no content
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: 01-simple-fifth-level-id
|
||||||
|
:END:
|
||||||
|
****** Empty sixth level
|
||||||
|
Loading…
Reference in New Issue
Block a user