Function: markdown-match-includes
markdown-match-includes is a byte-compiled function defined in
markdown-mode.el.
Signature
(markdown-match-includes LAST)
Documentation
Match include statements from point to LAST.
Sets match data for the following seven groups: Group 1: opening two angle brackets Group 2: opening title delimiter (optional) Group 3: title text (optional) Group 4: closing title delimiter (optional) Group 5: opening filename delimiter Group 6: filename Group 7: closing filename delimiter
Source Code
;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
(defun markdown-match-includes (last)
"Match include statements from point to LAST.
Sets match data for the following seven groups:
Group 1: opening two angle brackets
Group 2: opening title delimiter (optional)
Group 3: title text (optional)
Group 4: closing title delimiter (optional)
Group 5: opening filename delimiter
Group 6: filename
Group 7: closing filename delimiter"
(when (markdown-match-inline-generic markdown-regex-include last)
(let ((valid (not (or (markdown-in-comment-p (match-beginning 0))
(markdown-in-comment-p (match-end 0))
(markdown-code-block-at-pos (match-beginning 0))))))
(cond
;; Parentheses and maybe square brackets, but no curly braces:
;; match optional title in square brackets and file in parentheses.
((and valid (match-beginning 5)
(not (match-beginning 8)))
(set-match-data (list (match-beginning 1) (match-end 7)
(match-beginning 1) (match-end 1)
(match-beginning 2) (match-end 2)
(match-beginning 3) (match-end 3)
(match-beginning 4) (match-end 4)
(match-beginning 5) (match-end 5)
(match-beginning 6) (match-end 6)
(match-beginning 7) (match-end 7))))
;; Only square brackets present: match file in square brackets.
((and valid (match-beginning 2)
(not (match-beginning 5))
(not (match-beginning 7)))
(set-match-data (list (match-beginning 1) (match-end 4)
(match-beginning 1) (match-end 1)
nil nil
nil nil
nil nil
(match-beginning 2) (match-end 2)
(match-beginning 3) (match-end 3)
(match-beginning 4) (match-end 4))))
;; Only curly braces present: match file in curly braces.
((and valid (match-beginning 8)
(not (match-beginning 2))
(not (match-beginning 5)))
(set-match-data (list (match-beginning 1) (match-end 10)
(match-beginning 1) (match-end 1)
nil nil
nil nil
nil nil
(match-beginning 8) (match-end 8)
(match-beginning 9) (match-end 9)
(match-beginning 10) (match-end 10))))
(t
;; Not a valid match, move to next line and search again.
(forward-line)
(when (< (point) last)
(setq valid (markdown-match-includes last)))))
valid)))