Skip to content

Commit a1bd717

Browse files
committed
feat: add title in orgparse object in title method
1 parent 9184c9a commit a1bd717

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

orgparse/node.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,9 @@ def _parse_comments(self):
636636
for todokey in ['TODO', 'SEQ_TODO', 'TYP_TODO']:
637637
for val in special_comments.get(todokey, []):
638638
self.env.add_todo_keys(*parse_seq_todo(val))
639-
639+
# parse TITLE keys and store in title
640+
if 'TITLE' in special_comments:
641+
self.title = special_comments['TITLE'][0]
640642
# misc
641643

642644
@property

orgparse/tests/test_misc.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,18 @@ def test_add_custom_todo_keys():
8282
root = loads(content, filename, env)
8383
assert root.env.all_todo_keys == ['CUSTOM_TODO', 'COMMENT_TODO',
8484
'CUSTOM_DONE', 'COMMENT_DONE']
85+
86+
def test_add_custom_todo_keys():
87+
filename = '<string>' # default for loads
88+
content = """#+TITLE: Test title
89+
* Node 1
90+
test 1
91+
* Node 2
92+
test 2
93+
"""
94+
95+
env = OrgEnv(filename=filename)
96+
97+
# after parsing, all keys are set
98+
root = loads(content, filename, env)
99+
assert root.title == 'Test title'

0 commit comments

Comments
 (0)