emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Yann Esposito (yogsototh)" <yann.esposito@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Use CUSTOM_ID for outline-containers during HTML export
Date: Mon, 5 Aug 2019 15:39:31 +0200	[thread overview]
Message-ID: <1ACD8322-4973-41FE-9341-995D3C4DF98C@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2415 bytes --]

Hello,

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)" <yann.esposito@gmail.com>
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.
https://gitlab.esy.fun/yogsototh/org-auto-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 " ")
                           extra-class)
--
2.16.3

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

             reply	other threads:[~2019-08-05 13:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05 13:39 Yann Esposito (yogsototh) [this message]
2020-02-12 18:07 ` Use CUSTOM_ID for outline-containers during HTML export Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ACD8322-4973-41FE-9341-995D3C4DF98C@gmail.com \
    --to=yann.esposito@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).