~bzg/org-mode

b42867b5a13753888fca946f16f2f90c9e0d45c2 — Ihor Radchenko a month ago 4d3b216
org-html-toc: Fix duplicate ids when there are multiples TOCs

* lisp/ox-html.el (org-html-toc): When multiple TOCs are generated
inside the exported document, make sure that they do not have
duplicate IDs.

Reported-by: Michel Damiens <michel.damiens@gmail.com>
Link: https://orgmode.org/list/87sfj6av4t.fsf@localhost
1 files changed, 9 insertions(+), 4 deletions(-)

M lisp/ox-html.el
M lisp/ox-html.el => lisp/ox-html.el +9 -4
@@ 2462,14 2462,19 @@ of contents as a string, or nil if it is empty."
			 (org-export-get-relative-level headline info)))
		 (org-export-collect-headlines info depth scope))))
    (when toc-entries
      (let ((toc (concat "<div id=\"text-table-of-contents\" role=\"doc-toc\">"
			 (org-html--toc-text toc-entries)
			 "</div>\n")))
      (let* ((toc-id-counter (plist-get info :org-html--toc-counter))
             (toc (concat (format "<div id=\"text-table-of-contents%s\" role=\"doc-toc\">"
                                  (if toc-id-counter (format "-%d" toc-id-counter) ""))
			  (org-html--toc-text toc-entries)
			  "</div>\n")))
        (plist-put info :org-html--toc-counter (1+ (or toc-id-counter 0)))
	(if scope toc
	  (let ((outer-tag (if (org-html--html5-fancy-p info)
			       "nav"
			     "div")))
	    (concat (format "<%s id=\"table-of-contents\" role=\"doc-toc\">\n" outer-tag)
	    (concat (format "<%s id=\"table-of-contents%s\" role=\"doc-toc\">\n"
                            outer-tag
                            (if toc-id-counter (format "-%d" toc-id-counter) ""))
		    (let ((top-level (plist-get info :html-toplevel-hlevel)))
		      (format "<h%d>%s</h%d>\n"
			      top-level