Hello, Yesterday, I came up with a way to generate the HTML details disclosure fairly easily using Org Special Blocks. I implemented that in ox-hugo. But I believe the same would be useful for ox-html too.
Here's the relevant code snippet: ((string= block-type "details") ;; Recognize Org Special blocks like: ;; #+begin_details ;; summary. This will be wrapped in <summary> and </summary> ;; --- ;; details ;; #+end_details (let* ((is-open (member "open" (org-element-property :attr_html special-block))) (str1 (org-blackfriday-special-block special-block contents nil)) ;; Insert a new-line before the closing </details> tag ;; for correct Markdown parsing for cases when the ;; Special Block content ends a code block. Without this ;; inserted newline, the Markdown converted content will ;; look like below, and Blackfriday won't parse it ;; correctly. ;; ```emacs-lisp ;; (message "a code block") ;; ```</details> ;; A closing </p> tag is also added.. the opening <p> ;; tag is later added in the `str2' var if summary is ;; present, else in `str3' var. (str1 (replace-regexp-in-string "</details>\\'" "\n</p>\\&" str1)) ;; Detect the summary divider special string "---". It ;; must begin at the beginning of a line. Also ensure to ;; replace only the first match, if any. ;; Also add the opening <p> tag with "details" class ;; so that just as CSS rules can be set for summary ;; ("details summary"), they can be set for the details ;; portion following the <summary> too, using "details ;; .details". (str2 (replace-regexp-in-string "^\\(---\\)\n\\(.\\|\n\\)*\\'" "</summary><p class=\"details\">" str1 nil nil 1)) (has-summary (not (string= str1 str2))) str3) ;; (message "[DBG details/summary]: is-open:%S `%s' `%s'" is-open str1 str2) (setq str3 (if has-summary (replace-regexp-in-string "\\`<details>" "\\&<summary>" str2) (replace-regexp-in-string "\\`<details>" "\\&<p class=\"details\">" str2))) (if is-open (replace-regexp-in-string "\\`\\(<details\\)>" "\\1 open>" str3) str3))) I used "---" as the summary/details divider so that even if someone exports that Org document to HTML without that support in ox-html, it exports as Summary — Details. See this for examples: https://ox-hugo.scripter.co/doc/details-and-summary/ Here is the full org-hugo-special-block: https://github.com/kaushalmodi/ox-hugo/blob/14533c96195c90e417fcbde9d938650e83a39125/ox-hugo.el#L2239-L2363 If this feature is approved for addition to ox-html, I can make a formal patch where instead of looking for "---", I look for the appropriate string based on the value of (plist-get info :with-special-strings). Thanks! Kaushal -- Kaushal Modi