forked from kenkeiras/org-rw
Close PROPERTY drawers when there's no empty lines between headlines.
This commit is contained in:
parent
a164653cd0
commit
bd57dff091
3
.gitignore
vendored
3
.gitignore
vendored
@ -82,6 +82,9 @@ target/
|
|||||||
profile_default/
|
profile_default/
|
||||||
ipython_config.py
|
ipython_config.py
|
||||||
|
|
||||||
|
# Idea IDE
|
||||||
|
.idea
|
||||||
|
|
||||||
# pyenv
|
# pyenv
|
||||||
# For a library or package, you might want to ignore these files since the code is
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
# intended to run in multiple environments; otherwise, check them in:
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
@ -1472,6 +1472,20 @@ class OrgDoc:
|
|||||||
last_type = ltype
|
last_type = ltype
|
||||||
structured_lines.append(content)
|
structured_lines.append(content)
|
||||||
|
|
||||||
|
if last_type == PROPERTIES_T:
|
||||||
|
# No structural closing
|
||||||
|
|
||||||
|
indentation = 0
|
||||||
|
if len(lines) > 0:
|
||||||
|
last_line = lines[i - 1][1][1]
|
||||||
|
indentation = last_line.index(":")
|
||||||
|
structured_lines.append(" " * indentation + ":END:\n")
|
||||||
|
logging.warning(
|
||||||
|
"Added structural:{}: {}".format(
|
||||||
|
line[1][0], structured_lines[-1].strip()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if len(structured_lines) > 0:
|
if len(structured_lines) > 0:
|
||||||
content = "".join(structured_lines)
|
content = "".join(structured_lines)
|
||||||
|
|
||||||
|
6
tests/08-property-creation.org
Normal file
6
tests/08-property-creation.org
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#+TITLE: 08-Property-creation
|
||||||
|
|
||||||
|
* Top headline
|
||||||
|
** Second headline
|
||||||
|
|
||||||
|
*** Third headline
|
@ -507,3 +507,32 @@ class TestSerde(unittest.TestCase):
|
|||||||
hl = doc.getTopHeadlines()[0]
|
hl = doc.getTopHeadlines()[0]
|
||||||
self.assertEqual(hl.get_property("ID"), "419f4651-21c8-4166-b8d5-692c34be9f93")
|
self.assertEqual(hl.get_property("ID"), "419f4651-21c8-4166-b8d5-692c34be9f93")
|
||||||
self.assertEqual(len(hl.children), 1)
|
self.assertEqual(len(hl.children), 1)
|
||||||
|
|
||||||
|
def test_org_property_creation_08(self):
|
||||||
|
with open(os.path.join(DIR, "08-property-creation.org")) as f:
|
||||||
|
orig = f.read()
|
||||||
|
doc = loads(orig)
|
||||||
|
|
||||||
|
headline = doc.getTopHeadlines()[0]
|
||||||
|
headline.id = "first"
|
||||||
|
|
||||||
|
second = headline.children[0]
|
||||||
|
second.id = "second"
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
dumps(doc).strip(),
|
||||||
|
"""
|
||||||
|
#+TITLE: 08-Property-creation
|
||||||
|
|
||||||
|
* Top headline
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: first
|
||||||
|
:END:
|
||||||
|
** Second headline
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: second
|
||||||
|
:END:
|
||||||
|
|
||||||
|
*** Third headline
|
||||||
|
""".strip(),
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user