karlicoss / orgparse

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

New function in node.py #53

Closed sati-bodhi closed 1 year ago

sati-bodhi commented 2 years ago

I wrote a get_nodes_with_heading function in node.py for my own project so that one can easily zoom-in on nodes with a certain heading in the loaded document.

Example Usage:

from orgparse import loads
root = loads("""
* first
** second
*** third
* fourth
""")
root.get_nodes_with_heading("third")[0].heading
# Output: 'third'

Hope the community would find this useful.

karlicoss commented 1 year ago

Hey, thanks for the contribution. I am not sure it makes sense to keep in main node class because it's a bit too specific to your usecase -- at the very least this needs a test (otherwise someone else might break it by accident). I am willing to include it in a separate file like contrib.py if you want though -- that would mean it's not exposed as a public API, but still can be used by you. Feel free to do that and reopen if you want :)