karlicoss / orgparse

Python module for reading Emacs org-mode files
https://orgparse.readthedocs.org
BSD 2-Clause "Simplified" License
371 stars 43 forks source link

Question: Why is `_special_comments['TITLE']` a list? #51

Closed buhtz closed 2 years ago

buhtz commented 2 years ago

Sorry for asking as an Issue but I couldn't find another "channel" for that.

I am new to orgparse and org syntax. I would like to know why the TITLE entry in _special_comments is of type list? In my cases there is only one entry not more. In what cases would there be more then one element in that list? Maybe you can give an example org file to illustrate that.

>>> orgobj._special_comments['TITLE']
['My Title']
karlicoss commented 2 years ago

Hi! No worries, it's an okay channel :)

It seems that it's just the generic way parsing was implemented (because some special properties can be a list): https://github.com/karlicoss/orgparse/blob/349a61f7ba3f0cbdc753a780179b456b1ecb6038/orgparse/node.py#L795

In principle, you shouldn't need to use _special_comments, it's kinda internal field. There are get_file_property_list and get_file_property methods, and the latter can be used with TITLE to give you a single value. Hope it helps :)

https://github.com/karlicoss/orgparse/blob/349a61f7ba3f0cbdc753a780179b456b1ecb6038/orgparse/node.py#L1048-L1058