Whenever I export to html from an org mode buffer, section headings had numberings like “1 First section title”, “1.1 first subsection title”. I wanted to change that to “1. First section title”, “1.1. first subsection title”. The user option
org-export-section-number-format used to be there for this kind of customization, but is no longer supported. Someone suggested
org-html-format-headline-function which I have not figured out how to use. Nevertheless, I managed to do what I want with this code:
(defun my-html-filter-headline-yesdot (text backend info) "Ensure dots in headlines." (when (org-export-derived-backend-p backend 'html) (save-match-data (when (let ((case-fold-search t)) (string-match (rx (group "<span class=\"section-number-" (+ (char digit)) "\">" (+ (char digit "."))) (group "</span>")) text)) (replace-match "\\1.\\2" t nil text))))) (eval-after-load 'ox '(progn (add-to-list 'org-export-filter-headline-functions 'my-html-filter-headline-yesdot)))
2. how does it work
org-export-filter-headline-functions is where you can add your own function that post-process html segments. When your function returns
nil, it just means “I have no opinion on what to do in this case”, and when it returns a string, it should be the result of applying your own processing.
The code relies on the resulting html structure.