Skip to content

Commit c2aedeb

Browse files
rrudakovbbatsov
authored andcommitted
[#60] Fix issue with fontification when markdown-inline is enabled
Many thanks to Juri Linkov <[email protected]> for his assistance.
1 parent 63a9ea4 commit c2aedeb

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [#74](https://github.com/clojure-emacs/clojure-ts-mode/issues/74): Add imenu support for keywords definitions.
2323
- [#77](https://github.com/clojure-emacs/clojure-ts-mode/issues/77): Update grammars to the latest versions.
2424
- [#79](https://github.com/clojure-emacs/clojure-ts-mode/pull/79): Improve markdown highlighting in the docstrings.
25+
- [#60](https://github.com/clojure-emacs/clojure-ts-mode/issues/60): Fix issue with incorrect fontification, when `markdown-inline` is enabled.
2526

2627
## 0.2.3 (2025-03-04)
2728

clojure-ts-mode.el

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ if a third argument (the value) is provided.
345345
(treesit-range-rules
346346
:embed 'markdown-inline
347347
:host 'clojure
348+
:local t
348349
(clojure-ts--docstring-query '@capture)))
349350

350351
(defun clojure-ts--font-lock-settings (markdown-available)
@@ -1230,7 +1231,7 @@ It is simply `clojure-ts-docstring-fill-prefix-width' number of spaces."
12301231
(defun clojure-ts--fill-paragraph (&optional justify)
12311232
"Like `fill-paragraph', but can handler Clojure docstrings.
12321233
If JUSTIFY is non-nil, justify as well as fill the paragraph."
1233-
(let ((current-node (treesit-node-at (point))))
1234+
(let ((current-node (treesit-node-at (point) 'clojure)))
12341235
(if (clojure-ts--match-docstring nil current-node nil)
12351236
(let ((fill-column (or clojure-ts-docstring-fill-column fill-column))
12361237
(fill-prefix (clojure-ts--docstring-fill-prefix))
@@ -1260,11 +1261,20 @@ If JUSTIFY is non-nil, justify as well as fill the paragraph."
12601261
"map_lit" "ns_map_lit" "vec_lit" "set_lit")
12611262
"A regular expression that matches nodes that can be treated as lists.")
12621263

1264+
(defconst clojure-ts--markdown-inline-sexp-nodes
1265+
'("inline_link" "full_reference_link" "collapsed_reference_link"
1266+
"uri_autolink" "email_autolink" "shortcut_link" "image"
1267+
"code_span")
1268+
"Nodes representing s-expressions in the `markdown-inline' parser.")
1269+
12631270
(defconst clojure-ts--thing-settings
12641271
`((clojure
12651272
(sexp ,(regexp-opt clojure-ts--sexp-nodes))
12661273
(list ,(regexp-opt clojure-ts--list-nodes))
1267-
(text ,(regexp-opt '("comment"))))))
1274+
(text ,(regexp-opt '("comment"))))
1275+
(when clojure-ts-use-markdown-inline
1276+
(markdown-inline
1277+
(sexp ,(regexp-opt clojure-ts--markdown-inline-sexp-nodes))))))
12681278

12691279
(defvar clojure-ts-mode-map
12701280
(let ((map (make-sparse-keymap)))
@@ -1380,7 +1390,6 @@ See `clojure-ts--font-lock-settings' for usage of MARKDOWN-AVAILABLE."
13801390
(let ((use-markdown-inline (and clojure-ts-use-markdown-inline
13811391
(treesit-ready-p 'markdown-inline t))))
13821392
(when use-markdown-inline
1383-
(treesit-parser-create 'markdown-inline)
13841393
(setq-local treesit-range-settings clojure-ts--treesit-range-settings))
13851394

13861395
(when (treesit-ready-p 'clojure)

0 commit comments

Comments
 (0)