Browse Source

ox-html.el: Use CUSTOM_ID for outline-container-* div id

* lisp/ox-html.el (org-html-headline): When CUSTOM_ID is set, use it
to set the outline-container-* <div> id.

TINYCHANGE

When exporting HTML the exporter generate ids for references.
Unfortunately those id are not stable in the sense that exporting
twice generate two different set of ids.

Using CUSTOM_ID one could already use have fixed anchors in the
generated HTML. So for example we could share URL with
...index.html#my-section-id and it will be the same URL even if we
export the HTML again.

Unfortunately, this CUSTOM_ID is not used for the outline ids.  And
thus if we expose the html in a git repository for example.  Each
export will generate a big diff that "pollute" the diff because it
will show changes for all org items while most of them could still be
unchanged.

With this PR, HTML export will use CUSTOM_ID for both the headers id
and the org outline ids. For Items without CUSTOM_ID the behavior will
stay identical as before.
Yann Esposito (yogsototh) 5 months ago
parent
commit
da62654cb1
1 changed files with 1 additions and 2 deletions
  1. 1 2
      lisp/ox-html.el

+ 1 - 2
lisp/ox-html.el

@@ -2578,8 +2578,7 @@ holding contextual information."
               (first-content (car (org-element-contents headline))))
           (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
                   (org-html--container headline info)
-                  (concat "outline-container-"
-			  (org-export-get-reference headline info))
+                  (format "outline-container-%s" id)
                   (concat (format "outline-%d" level)
                           (and extra-class " ")
                           extra-class)