Function: markdown-ts--fontify-thematic-break

markdown-ts--fontify-thematic-break is a byte-compiled function defined in markdown-ts-mode.el.gz.

Signature

(markdown-ts--fontify-thematic-break NODE OVERRIDE START END &rest _)

Documentation

Fontify thematic break NODE and show a line when markup is hidden.

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-thematic-break (node override start end &rest _)
  "Fontify thematic break NODE and show a line when markup is hidden.
OVERRIDE, START, and END are passed through to
`treesit-fontify-with-override'."
  (let ((node-start (treesit-node-start node))
        (node-end (treesit-node-end node)))
    (treesit-fontify-with-override node-start node-end
                                   'markdown-ts-thematic-break
                                   override start end)
    (if markdown-ts-hide-markup
        (cond
         ((and (display-supports-face-attributes-p '(:extend t))
               (face-attribute 'markdown-ts-thematic-break
                               :extend nil 'default))
          (put-text-property node-start node-end
                             'display
                             (propertize "\n" 'face '(:extend t :underline t))))
         (t
          (when-let* ((char (markdown-ts--resolve-display-value
                             markdown-ts-thematic-break-character))
                      (_ (char-displayable-p char)))
            (let* ((col (save-excursion (goto-char node-start)
                                        (current-column)))
                   (span-length (max 12 (- (window-body-width) col))))
              (put-text-property node-start node-end
                                 'display
                                 (concat
                                  (make-string span-length char)
                                  "\n"))))))
      (remove-text-properties node-start node-end '(display nil)))))