Function: markdown-ts--fontify-link-node
markdown-ts--fontify-link-node is a byte-compiled function defined in
markdown-ts-mode.el.gz.
Signature
(markdown-ts--fontify-link-node NODE OVERRIDE START END &rest _)
Documentation
Fontify link or image text NODE as a clickable button.
Works for inline links, reference links, shortcut links, and
image descriptions. The URL is taken from a sibling
link_destination node when present, or resolved from a
link reference definition, or the node text itself is used as
fallback. OVERRIDE, START, and END are passed through to
treesit-fontify-with-override.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts--fontify-link-node (node override start end &rest _)
"Fontify link or image text NODE as a clickable button.
Works for inline links, reference links, shortcut links, and
image descriptions. The URL is taken from a sibling
`link_destination' node when present, or resolved from a
link reference definition, or the node text itself is used as
fallback. OVERRIDE, START, and END are passed through to
`treesit-fontify-with-override'."
(let ((parent (treesit-node-parent node)))
;; When NODE is a link_label inside a full_reference_link that
;; also has a link_text, skip it, link_text handles that link.
(unless (and (string= (treesit-node-type node) "link_label")
(treesit-search-subtree parent "\\`link_text\\'"))
(treesit-fontify-with-override
(treesit-node-start node) (treesit-node-end node)
'markdown-ts-link override start end)
(let* ((dest (treesit-search-subtree parent "\\`link_destination\\'"))
(url (if dest
(treesit-node-text dest t)
;; Reference links: resolve via link_label or link_text.
(let* ((label-node (treesit-search-subtree
parent "\\`link_label\\'"))
(label (if label-node
(string-trim (treesit-node-text
label-node t)
"\\[" "\\]")
(treesit-node-text node t))))
(or (markdown-ts--resolve-link-ref label)
label)))))
(markdown-ts--make-link-button
(treesit-node-start node) (treesit-node-end node) url)))))