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.
This commit is contained in:
Yann Esposito (yogsototh) 2020-02-12 19:00:42 +01:00 committed by Bastien
parent 73445c0fab
commit da62654cb1
1 changed files with 1 additions and 2 deletions

View File

@ -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)