The following lisp code introduces the new export keyword TOC_NO_HEADING
. If it has the value t
or yes
the heading of the table of contents is surpressed.
(require 'ox-html)
;; Adding keyword TOC_NO_HEADING to html export keywords:
(push '(:html-toc-no-heading "TOC_NO_HEADING" nil nil t) (org-export-backend-options (org-export-get-backend 'html)))
(defun my-org-html-toc-no-heading (args)
"Avoid toc heading in html export if the keyword TOC_HO_HEADING is t or yes.
Works as a :filter-args advice for `org-html-toc' with argument list ARGS."
(let* ((depth (nth 0 args))
(info (nth 1 args))
(scope (nth 2 args)))
(when (and (assoc-string (plist-get info :html-toc-no-heading) '(t yes) t)
(null scope))
(setq scope (plist-get info :parse-tree)))
(list depth info scope)))
(advice-add 'org-html-toc :filter-args #'my-org-html-toc-no-heading)
Test:
emacs-version
26.1
org-version
9.1.13
- Test file:
#+TOC_NO_HEADING: t
* Test header 1
** Test header 1.1
Some text below test header 1.1.
** Test header 1.2
Some text below test header 1.2.
* Header 2
Some text below header 2.
org-html-toc
inox-html.el
always adds a "Table of Contents" string to the output. It uses(org-html--translate "Table of Contents" info)
, so you could invent a fake language, sayen-no-toc
, so the translation of "Table of Contents" is the empty string. That would erase the text but leave an empty heading in the HTML. If you don't like that, you can redefine this function to omit it. Or you could use CSS to hide the heading (hide the element withid="table-of-contents"
and override this in the child with `id="text-table-of-contents", so it shows).