[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Use CUSTOM_ID for outline-containers during HTML export

From: Yann Esposito (yogsototh)
Subject: [O] Use CUSTOM_ID for outline-containers during HTML export
Date: Mon, 5 Aug 2019 15:39:31 +0200


I would like to submit a simple patch that could make the HTML exporter closer 
to reproductible build.
I have given a bit more information in my commit below.

From 5d59d1e0b10430830aff77c17be1d37bb9e898bc Mon Sep 17 00:00:00 2001
From: "Yann Esposito (Yogsototh)" <address@hidden>
Date: Mon, 5 Aug 2019 15:20:25 +0200
Subject: [PATCH] Use CUSTOM_ID for outline-containers

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.

n.b.: I've create a private package to generate meaningful CUSTOM_ID.

For my use case, it would be really preferable that those generated
ids use the content of org item.

p.s: if for some reason this patch might break some usage.
I would like to at least be able to provide an option
to disable the generation of those outline-container div.
 lisp/ox-html.el | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 757006321..8056adc91 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2634,8 +2634,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 " ")

Attachment: signature.asc
Description: Message signed with OpenPGP

reply via email to

[Prev in Thread] Current Thread [Next in Thread]