1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-05-31 01:32:00 -07:00

Fix markdown-ts-mode atx_heading face computation (bug#81042)

The grammar reports leading spaces as part of the atx_heading "marker"
and we cannot use the length of the marker as a result.  Instead, count
the number of consecutive # after any blanks to determine its "level."

* lisp/textmodes/markdown-ts-mode.el
(markdown-ts--fontify-atx-heading): Count the octothorpes rather
than using the length of the marker node's text.
This commit is contained in:
Stéphane Marks 2026-05-14 14:08:02 -04:00 committed by João Távora
parent 997fc2cef7
commit e0aeee2dc5

View file

@ -1093,8 +1093,12 @@ CommonMark they are decorative and must be preceded by a space or tab."
(let* ((n-start (treesit-node-start node))
(n-end (treesit-node-end node))
(face (let ((marker (treesit-node-child node 0)))
(intern (format "markdown-ts-heading-%d"
(length (treesit-node-text marker t)))))))
(intern
(format "markdown-ts-heading-%d"
(progn
(string-match "[[:blank:]]*\\([#]+\\)"
(treesit-node-text marker t))
(- (match-end 1) (match-beginning 1))))))))
(font-lock--remove-face-from-text-property n-start n-end 'face face)
(font-lock-append-text-property n-start (1- n-end) 'face face)
(save-excursion