snosov1 / toc-org

toc-org is an Emacs utility to have an up-to-date table of contents in the org files without exporting (useful primarily for readme files on GitHub)
GNU General Public License v3.0
286 stars 29 forks source link

Ignore some headings #14

Closed alphapapa closed 7 years ago

alphapapa commented 8 years ago

Hi,

I use toc-org for the readme in https://github.com/alphapapa/org-protocol-capture-html, and it works great, but I would like to be able to leave out some headings from the TOC, like the ones above it.

It would be nice if toc-org supported a tag or property to ignore certain headings, similar to how org-mode export ignores the :ignore: tag.

Thanks for your work on toc-org!

snosov1 commented 8 years ago

Hey! Thanks for the suggestion!

Currently, I'm traveling, so don't really have the time to look at it right now. I'll look into it in a couple of weeks.

I was thinking about something like that some time ago. But I had :noexport: tag in my mind. I'm not aware that :ignore: tag has any special meaning in org markup. Is it documented anywhere? The reason I'm asking is I don't really want to overcomplicate this package and introduce special rules and behavior just for the sake of this package. I want to preserve the rules very simple and follow the principle of least surprise.

As a workaround for your "todo" headings you can simply make them one level deeper, so they don't appear in the TOC.

alphapapa commented 8 years ago

Sorry, :noexport: is the right tag, I must have been thinking of something else.

Another possibility might be to have an option for toc-org to not include headings above the TOC itself. That would take care of this use-case for me, and it wouldn't require tagging headings. Basically it would be as if the headings before the TOC itself were introductory material, sort of like a title page, and since whoever's reading the TOC has already seen them, they could be left out of the TOC, haha. :)

What do you think? If I have time before you return, I might see if I could figure it out and send a PR.

snosov1 commented 8 years ago

Another possibility might be to have an option for toc-org to not include headings above the TOC itself.

Nah, I don't really like this =) It doesn't feel right =)

Handling :noexport: the same way as org export might be the way to go. It seems most natural to me. However, I wonder if there are meaningful cases where this behavior could be undesired. I'm not 100% sure yet. Only, like, 95% =)

alphapapa commented 8 years ago

I took a look at the code, and it turned out to be a very simple patch to make an option to skip pre-toc headings, so I went ahead and made a PR to add the option, off by default. It works great for my use-case. If you don't want to include it I guess I'll keep my little fork. :)

I also noticed a comment mentioning :noexport:, so I guess you already thought of that. :) Let me know if you would like me to see if I could implement that. However, I think it should probably use a different tag, because using that tag would make Org itself not export those subtrees. Maybe a :notoc: tag? Or maybe a toc-org: ignore property?

Thanks.

titaniumbones commented 7 years ago

the other thing that org ignores is headlines marked as comments:

Do you see a way to do that?

Taking a quick look at the code, it seems to me it would be easier to do so by using the org-element API

snosov1 commented 7 years ago

Hey, @titaniumbones!

I've just merged https://github.com/snosov1/toc-org/pull/37 It should do the trick with COMMENTed headlines. Please, give it a try and see if it works as intended!

snosov1 commented 7 years ago

Fixed by https://github.com/snosov1/toc-org/pull/39