用 ox-publish 的 :with-toc nil 是不显示目录,怎么隐藏掉 “Table of Contents” ?
CSS or JS
方法1: 加入到 ox-publish
配置中(推荐):
:html-head "<style>#table-of-contents h2 { display: none; }</style>"
方法2: OR, 把这行加入到引入的 CSS 文件中(如果有):
#table-of-contents h2 { display: none; }
方法3: OR,直接加入这段到你的 Org 文件中(不推荐):
#+BEGIN_EXPORT html
<style>#table-of-contents h2 { display: none; }</style>
#+END_EXPORT
可以试试:org-export-filter-headline-functions, 也可以试试 advice 下面的函数
(defun org-html-toc (depth info &optional scope)
"Build a table of contents.
DEPTH is an integer specifying the depth of the table. INFO is
a plist used as a communication channel. Optional argument SCOPE
is an element defining the scope of the table. Return the table
of contents as a string, or nil if it is empty."
(let ((toc-entries
(mapcar (lambda (headline)
(cons (org-html--format-toc-headline headline info)
(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")))
(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)
(let ((top-level (plist-get info :html-toplevel-hlevel)))
(format "<h%d>%s</h%d>\n"
top-level
(org-html--translate "Table of Contents" info)
top-level))
toc
(format "</%s>\n" outer-tag))))))))
兄弟,我现在用的就是这个方案 hhhhh 但我希望的答案是你楼下那个老哥的 /dog