Function: markdown-ts--link-ref-definitions
markdown-ts--link-ref-definitions is a byte-compiled function defined
in markdown-ts-mode.el.gz.
Signature
(markdown-ts--link-ref-definitions)
Documentation
Return an alist of (LABEL . URL) from link reference definitions.
LABEL is downcased for case-insensitive matching. Results are cached and rebuilt only when the buffer changes.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts--link-ref-definitions ()
"Return an alist of (LABEL . URL) from link reference definitions.
LABEL is downcased for case-insensitive matching. Results are
cached and rebuilt only when the buffer changes."
(let ((tick (buffer-chars-modified-tick)))
(unless (eq tick markdown-ts--link-ref-cache-tick)
(let* ((root (treesit-buffer-root-node 'markdown))
(matches (treesit-query-capture
root
'((link_reference_definition
(link_label) @label
(link_destination) @dest))))
defs)
(while matches
(let* ((label-pair (pop matches))
(dest-pair (pop matches))
(lbl-text (string-trim (treesit-node-text (cdr label-pair) t)
"\\[" "\\]")))
(push (cons (downcase lbl-text)
(treesit-node-text (cdr dest-pair) t))
defs)))
(setq markdown-ts--link-ref-cache (nreverse defs)
markdown-ts--link-ref-cache-tick tick)))
markdown-ts--link-ref-cache))