Function: markdown-ts--fontify-setext-heading
markdown-ts--fontify-setext-heading is a byte-compiled function
defined in markdown-ts-mode.el.gz.
Signature
(markdown-ts--fontify-setext-heading NODE OVERRIDE START END &rest _)
Documentation
Apply the heading face across a setext NODE.
Layer the face on top of child sub-nodes (e.g. an inline link) so
their own faces are preserved. Strip any prior copy of the face
first so it does not accumulate when the heading is refontified or
its level/type changes during editing.
Apply the face to the setext heading_content separately from the
underline rather than treat them as a single range. This avoids putting
the face on the heading_content newline. If markdown-ts-hide-markup
is non-nil, hide the underline line entirely by setting its line-height
text property to 0.
Elide trailing whitespace when hiding markup.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts--fontify-setext-heading (node _override _start _end &rest _)
"Apply the heading face across a setext NODE.
Layer the face on top of child sub-nodes (e.g. an inline link) so
their own faces are preserved. Strip any prior copy of the face
first so it does not accumulate when the heading is refontified or
its level/type changes during editing.
Apply the face to the setext heading_content separately from the
underline rather than treat them as a single range. This avoids putting
the face on the heading_content newline. If `markdown-ts-hide-markup'
is non-nil, hide the underline line entirely by setting its line-height
text property to 0.
Elide trailing whitespace when hiding markup."
(let* ((n-start (treesit-node-start node))
(n-end (treesit-node-end node))
(content (treesit-node-child node 0 'named))
(content-start (treesit-node-start content))
(content-end (treesit-node-end content))
(underline (treesit-node-child node 1 'named))
(underline-start (treesit-node-start underline))
(underline-end (treesit-node-end underline))
(face 'markdown-ts-setext-heading))
(font-lock--remove-face-from-text-property n-start n-end 'face face)
;; 1- content-end avoids the newline so it hides correctly.
(font-lock-append-text-property content-start (1- content-end) 'face face)
(font-lock-append-text-property underline-start underline-end 'face face)
(when markdown-ts-hide-markup
;; Hide heading_content trailing spaces.
(put-text-property (save-excursion
(goto-char content-end)
(skip-chars-backward "[:space:]" content-start)
(point))
content-end
'invisible 'markdown-ts--markup)
(put-text-property underline-start underline-end 'line-height 0))))