Config: a little elisp reformatting

This commit is contained in:
TEC 2021-03-29 22:54:31 +08:00
parent 1afd9eaca5
commit dd58e88faa
Signed by: tec
GPG Key ID: 779591AFDB81F06C
1 changed files with 21 additions and 20 deletions

View File

@ -6663,26 +6663,26 @@ is an element defining the scope of the table. Return the table
of contents as a string, or nil if it is empty."
:override #'org-html-toc
(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))))
(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\">"
(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\">\n" outer-tag)
(let ((top-level (plist-get info :html-toplevel-hlevel)))
(format "<h%d><a href=\"#\" style=\"color:inherit; text-decoration: none;\">%s</a></h%d>\n"
top-level
(org-html--translate "Table of Contents" info)
top-level))
toc
(format "</%s>\n" outer-tag))))))))
(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\">\n" outer-tag)
(let ((top-level (plist-get info :html-toplevel-hlevel)))
(format "<h%d><a href=\"#\" style=\"color:inherit; text-decoration: none;\">%s</a></h%d>\n"
top-level
(org-html--translate "Table of Contents" info)
top-level))
toc
(format "</%s>\n" outer-tag))))))))
#+end_src
Lastly, let's pile on some metadata. This gives my pages nice embeds.
@ -6806,8 +6806,9 @@ and a button to copy the content of the block.
ref
(if collapsed-p "" " open")
(if name " class='named'" "")
(if (not name) (concat "<span class='lang'>" lang "</span>")
(format "<span class='name'>%s</span><span class='lang'>%s</span>" name lang))
(concat
(when name (concat "<span class=\"name\">" name "</span>"))
"<span class=\"lang\">" lang "</span>")
ref
(if name
(replace-regexp-in-string (format "<pre\\( class=\"[^\"]+\"\\)? id=\"%s\">" ref) "<pre\\1>"