Function: markdown-insert-foldable-block
markdown-insert-foldable-block is an interactive and byte-compiled
function defined in markdown-mode.el.
Signature
(markdown-insert-foldable-block)
Documentation
Insert details disclosure element to make content foldable.
If a region is active, wrap this region with the disclosure element. More details here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
(defun markdown-insert-foldable-block ()
"Insert details disclosure element to make content foldable.
If a region is active, wrap this region with the disclosure
element. More details here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details."
(interactive)
(let ((details-open-tag "<details>")
(details-close-tag "</details>")
(summary-open-tag "<summary>")
(summary-close-tag " </summary>"))
(if (use-region-p)
(let* ((b (region-beginning))
(e (region-end))
(indent (progn (goto-char b) (current-indentation))))
(goto-char e)
;; if we're on a blank line, don't newline, otherwise the tags
;; should go on its own line
(unless (looking-back "\n" nil)
(newline))
(indent-to indent)
(insert details-close-tag)
(markdown-ensure-blank-line-after)
(goto-char b)
;; if we're on a blank line, insert the quotes here, otherwise
;; add a new line first
(unless (looking-at-p "\n")
(newline)
(forward-line -1))
(markdown-ensure-blank-line-before)
(indent-to indent)
(insert details-open-tag "\n")
(insert summary-open-tag summary-close-tag)
(search-backward summary-close-tag))
(let ((indent (current-indentation)))
(delete-horizontal-space :backward-only)
(markdown-ensure-blank-line-before)
(indent-to indent)
(insert details-open-tag "\n")
(insert summary-open-tag summary-close-tag "\n")
(insert details-close-tag)
(indent-to indent)
(markdown-ensure-blank-line-after)
(search-backward summary-close-tag)))))