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
292 stars 29 forks source link

Links don't work if headline has any TODO or statistics-cookie #28

Closed VladimirAlexiev closed 8 years ago

VladimirAlexiev commented 8 years ago

Look at https://github.com/VladimirAlexiev/VladimirAlexiev.github.io/blob/master/Multisensor/validation.org. Only the first two links work, because the other headlines have a TODO or statistics-cookie, but Github doesn't strip these when generating the preview. Eg

This means that:

snosov1 commented 8 years ago

for TODO Underscores to Spaces, github generates #todo-underscores-to-spaces but you link to #underscores-to-spaces

Not exactly. By default, GitHub strips TODO keywords. But it seems to leave it if you have #+OPTIONS: todo:t in your file. I think that's fixable.

snosov1 commented 8 years ago

I've pushed statistics cookies handling to https://github.com/snosov1/toc-org/tree/handle-statistics-cookies

Please, check this if you have a chance.

Next, I'll try to figure something out about TODO handling.

VladimirAlexiev commented 8 years ago

Here's a quick patch re TODO:

      ;; strip states
      (unless org-export-with-todo-keywords
        (goto-char (point-min))
        (while (re-search-forward toc-org-states-regexp nil t)
          (replace-match "" nil nil nil 1)))

toc-org-states-regexp hard-codes a few, but as you know I can customize them in the file. Eg my file validation.org has

#+TODO: TODO QUE | DONE CANCEL

And so if I evaluate the following variables I get

org-todo-keywords ;; ("TODO" "QUE")
org-done-keywords ;; ("DONE" "CANCEL")

All these are put in org-todo-line-regexp, which is used in (org-get-todo-state). The keyword is in match group 2.

NOW, whether you use the hard-coded toc-org-states-regexp or org functions to process this, depends on whether GitHub processes the #+TODO heading.

Cheers!

snosov1 commented 8 years ago

I've re-implemented the fixes in https://github.com/snosov1/toc-org/tree/fix-28, since I didn't like the original implementation. Both issues seem to be fixed there, so, please, give it a try.

A couple of comments:

Here's a quick patch re TODO:

Thx! However, you can't use org-export-with-todo-keywords variable in this package, since GitHub doesn't know about it. I've implemented something similar.\

toc-org-states-regexp hard-codes a few, but as you know I can customize them in the file.

GitHub was handling only TODO and DONE states the last time I checked. So, no plans to support anything else either.

snosov1 commented 8 years ago

I've also added a couple of tests. Personally, I'm ready to merge it - please, have a look, and if you're ok with it, let's merge & close this:

https://github.com/snosov1/toc-org/tree/fix-28

VladimirAlexiev commented 8 years ago

looks ok