Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table of contents headline links are exported with incorrect references #82

Open
tylerjl opened this issue Mar 27, 2025 · 0 comments · May be fixed by #83
Open

Table of contents headline links are exported with incorrect references #82

tylerjl opened this issue Mar 27, 2025 · 0 comments · May be fixed by #83

Comments

@tylerjl
Copy link

tylerjl commented Mar 27, 2025

Hi! Thanks so much for weblorg. ❤

I've found that when including a table of contents with a line like the following:

#+TOC: headlines 2

The resulting HTML includes unique org links (of the form #org865011c) rather then the cleaned-up :CUSTOM_ID values that get inserted as part of the weblorg--parse-org advice overrides.

I've managed to get it working by adding another advice-add in the function that does something like this:

(advice-add
 #'org-html--reference :around
 (lambda(fn datum info &optional named-only)
   (if (and
    (memq (org-element-type datum) '(headline))
    (not (org-element-property :CUSTOM_ID datum)))
       (if-let ((headline-slug (weblorg--slugify (org-element-property :raw-value datum))))
           (org-element-put-property datum :CUSTOM_ID headline-slug)))
   (funcall fn datum info named-only)))

So I think that something like it will probably reliably work. I can either upstream something cleaner, or if somebody knows more about what they're doing than I do (😅 ) then that's great too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant