Function: markdown-complete-atx
markdown-complete-atx is a byte-compiled function defined in
markdown-mode.el.
Signature
(markdown-complete-atx)
Documentation
Complete and normalize ATX headers.
Add or remove hash marks to the end of the header to match the
beginning. Ensure that there is only a single space between hash
marks and header text. Removes extraneous whitespace from header text.
Assumes match data is available for markdown-regex-header-atx.
Return nil if markup was complete and non-nil if markup was completed.
Source Code
;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
(defun markdown-complete-atx ()
"Complete and normalize ATX headers.
Add or remove hash marks to the end of the header to match the
beginning. Ensure that there is only a single space between hash
marks and header text. Removes extraneous whitespace from header text.
Assumes match data is available for `markdown-regex-header-atx'.
Return nil if markup was complete and non-nil if markup was completed."
(when (markdown-incomplete-atx-p)
(let* ((new-marker (make-marker))
(new-marker (set-marker new-marker (match-end 2))))
;; Hash marks and spacing at end
(goto-char (match-end 2))
(delete-region (match-end 2) (match-end 3))
(insert " " (match-string 1))
;; Remove extraneous whitespace from title
(replace-match (markdown-compress-whitespace-string (match-string 2))
t t nil 2)
;; Spacing at beginning
(goto-char (match-end 1))
(delete-region (match-end 1) (match-beginning 2))
(insert " ")
;; Leave point at end of text
(goto-char new-marker))))