Skip to content

Commit 16b3183

Browse files
Regenerate README.md
1 parent 03257d7 commit 16b3183

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ Ox-html-stable-ids is disabled by default, even after requiring and enabling the
3737

3838
The function that generates headlines in Org's HTML exporer (`org-html-headline`) calls a function called `org-export-get-reference` to generate a unique reference for the headline. Ox-html-stable-ids adds an advice to overrides that function to return stable IDs, based on the headline's contents, instead.<sup><a id="fnr.adam-porter" class="footref" href="#fn.adam-porter" role="doc-backlink">1</a></sup>
3939

40-
First, the `org-html-stable-ids--extract-id` helper function takes a headline and returns a stable ID:
40+
First, the `org-html-stable-ids--extract-id` helper function takes an element and returns a stable ID:
4141

4242
```emacs-lisp
43+
(defun org-html-stable-ids--extract-value (datum)
44+
(let ((value (or (org-element-property :raw-value datum)
45+
(org-element-property-raw :value datum))))
46+
(unless (org-element-deferred-p value)
47+
value)))
48+
4349
(defun org-html-stable-ids--extract-id (datum)
4450
"Extract a reference from a DATUM.
4551
@@ -48,14 +54,14 @@ Return DATUM's `:CUSTOM_ID` if set, or generate a reference from its
4854
nil."
4955
(or
5056
(org-element-property :CUSTOM_ID datum)
51-
(let ((value (org-element-property :raw-value datum)))
57+
(let ((value (org-html-stable-ids--extract-value datum)))
5258
(when value
5359
(org-html-stable-ids--to-kebab-case value)))))
5460
```
5561

56-
If the headline has a `:CUSTOM_ID` property, that's immediately returned. If not, the ID is created by taking the headline's contents and converting them to "kebab case".
62+
If the element has a `:CUSTOM_ID` property, that's immediately returned. If not, element's contents are used through the `org-html-stable-ids--extract-value` function. To create te ID, the value is then converted to "kebab case".
5763

58-
<div class="aside" id="orgb17faff">
64+
<div class="aside" id="org8238144">
5965
<p>
6066

6167
</p>
@@ -70,7 +76,7 @@ An implementation in Emacs Lisp uses a regular expression to replace everything
7076
</p>
7177

7278
<div class="org-src-container">
73-
<pre class="src src-emacs-lisp" id="orgd3c8aed">(defun org-html-stable-ids--to-kebab-case (string)
79+
<pre class="src src-emacs-lisp" id="org682529d">(defun org-html-stable-ids--to-kebab-case (string)
7480
"Convert STRING to kebab-case."
7581
(string-trim
7682
(replace-regexp-in-string

0 commit comments

Comments
 (0)