Write a modified org-html-format-headline-function
that calls a modified org-html--tags
function and hook it into the standard HTML exporter by redefining/customizing the variable org-html-format-headline-function
.
Here's a possible implementation:
#+begin_src elisp
(defun ndk/org-html-format-headline-function
(todo _todo-type priority text tags info)
"Default format function for a headline.
See `org-html-format-headline-function' for details."
(let ((todo (org-html--todo todo info))
(priority (org-html--priority priority info))
(tags (ndk/org-html--tags tags info)))
(concat todo (and todo " ")
priority (and priority " ")
text
tags)))
(defun ndk/org-html--tags (tags info)
"Format TAGS into HTML.
INFO is a plist containing export options."
(when tags
(format "<span class=\"tag\">%s</span>"
(mapconcat
(lambda (tag)
(format "<a href=\"%s\">%s</a>"
(format "./%s.html" (downcase tag))
tag))
tags " "))))
;; (setq org-html-format-headline-function #'org-html-format-headline-default-function)
(setq org-html-format-headline-function #'ndk/org-html-format-headline-function)
#+end_src
If you compare the two functions above with the standard ones in ox-html.el
, you should be able to see clearly the small differences between them (and how to modify them further if needed).
For testing, the two setq
forms at the end are convenient: comment one or the other out to get either the default or the modified behavior. When you are satisfied with the functions, you should probably customize the variable org-html-format-headline-function
to set the whole thing in stone.