Function: markdown-syntax-propertize-list-items

markdown-syntax-propertize-list-items is a byte-compiled function defined in markdown-mode.el.

Signature

(markdown-syntax-propertize-list-items START END)

Documentation

Propertize list items from START to END.

Stores nested list item information in the markdown-list-item text property to make later syntax analysis easier. The value of this property is a list with elements of the form (begin . end) giving the bounds of the current and parent list items.

Source Code

;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
(defun markdown-syntax-propertize-list-items (start end)
  "Propertize list items from START to END.
Stores nested list item information in the `markdown-list-item'
text property to make later syntax analysis easier.  The value of
this property is a list with elements of the form (begin . end)
giving the bounds of the current and parent list items."
  (save-excursion
    (goto-char start)
    (let ((prev-list-line -100)
          bounds level pre-regexp)
      ;; Find a baseline point with zero list indentation
      (markdown-search-backward-baseline)
      ;; Search for all list items between baseline and END
      (while (and (< (point) end)
                  (re-search-forward markdown-regex-list end 'limit))
        ;; Level of list nesting
        (setq level (length bounds))
        ;; Pre blocks need to be indented one level past the list level
        (setq pre-regexp (format "^\\(    \\|\t\\)\\{%d\\}" (1+ level)))
        (beginning-of-line)
        (cond
         ;; Reset at headings, horizontal rules, and top-level blank lines.
         ;; Propertize baseline when in range.
         ((markdown-new-baseline)
          (setq bounds nil))
         ;; Make sure this is not a line from a pre block
         ((and (looking-at-p pre-regexp)
               ;; too indented line is also treated as list if previous line is list
               (>= (- (line-number-at-pos) prev-list-line) 2)))
         ;; If not, then update levels and propertize list item when in range.
         (t
          (let* ((indent (current-indentation))
                 (cur-bounds (markdown--cur-list-item-bounds))
                 (first (cl-first cur-bounds))
                 (last (cl-second cur-bounds))
                 (marker (cl-fifth cur-bounds)))
            (setq bounds (markdown--append-list-item-bounds
                          marker indent cur-bounds bounds))
            (when (and (<= start (point)) (<= (point) end))
              (setq prev-list-line (line-number-at-pos first))
              (put-text-property first last 'markdown-list-item bounds)))))
        (end-of-line)))))