alphapapa / alphapapa/org-make-toc

modified to keep existing CUSTOM_IDs

Open
#33 1 comment 0 reactions 1 assignee Claimed by @alphapapa View on GitHub
bug enhancement
Dominant language
Emacs Lisp
Stars
116
Forks
18
PR merge metrics
No merged PRs in 30d

Description

```
(defun org-make-toc--link-entry-github (pos)
"Return text for entry at POS converted to GitHub style link."
(-when-let* ((title (org-link-display-format (org-entry-get pos "ITEM")))
(target (--> title
org-link-display-format
(downcase it)
(replace-regexp-in-string " " "-" it)
(replace-regexp-in-string "[^[:alnum:]_-]" "" it)))
(filename (if org-make-toc-filename-prefix
(file-name-nondirectory (buffer-file-name))
"")))
(let ((existing-id (org-entry-get pos "CUSTOM_ID")))
;; Only set the CUSTOM_ID if it doesn't already exist
(unless existing-id
(when org-make-toc-insert-custom-ids
(setf target (or (gethash pos org-make-toc-ids)
(setf (gethash pos org-make-toc-ids)
(org-make-toc--disambiguate target))))
(org-set-property "CUSTOM_ID" target)))
(org-link-make-string (concat filename "#" (or existing-id target))
(org-make-toc--visible-text title)))))

```

thank you very much for all you do!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.