Function: markdown-cleanup-list-numbers-level
markdown-cleanup-list-numbers-level is a byte-compiled function
defined in markdown-mode.el.
Signature
(markdown-cleanup-list-numbers-level &optional PFX PREV-ITEM)
Documentation
Update the numbering for level PFX (as a string of spaces) and PREV-ITEM.
PREV-ITEM is width of previous-indentation and list number
Assume that the previously found match was for a numbered item in a list.
Source Code
;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
(defun markdown-cleanup-list-numbers-level (&optional pfx prev-item)
"Update the numbering for level PFX (as a string of spaces) and PREV-ITEM.
PREV-ITEM is width of previous-indentation and list number
Assume that the previously found match was for a numbered item in
a list."
(let ((cpfx pfx)
(cur-item nil)
(idx 0)
(continue t)
(step t)
(sep nil))
(while (and continue (not (eobp)))
(setq step t)
(cond
((looking-at "^\\(\\([\s-]*\\)[0-9]+\\)\\. ")
(setq cpfx (match-string-no-properties 2))
(setq cur-item (match-string-no-properties 1)) ;; indentation and list marker
(cond
((or (= (length cpfx) (length pfx))
(= (length cur-item) (length prev-item)))
(save-excursion
(replace-match
(if (not markdown-ordered-list-enumeration)
(concat pfx "1. ")
(cl-incf idx)
(concat pfx (number-to-string idx) ". "))))
(setq sep nil))
;; indented a level
((< (length pfx) (length cpfx))
(setq sep (markdown-cleanup-list-numbers-level cpfx cur-item))
(setq step nil))
;; exit the loop
(t
(setq step nil)
(setq continue nil))))
((looking-at "^\\([\s-]*\\)[^ \t\n\r].*$")
(setq cpfx (match-string-no-properties 1))
(cond
;; reset if separated before
((string= cpfx pfx) (when sep (setq idx 0)))
((string< cpfx pfx)
(setq step nil)
(setq continue nil))))
(t (setq sep t)))
(when step
(beginning-of-line)
(setq continue (= (forward-line) 0))))
sep))