From 9c53af70cb8952b61cf5085ef345c81a6ab49d66 Mon Sep 17 00:00:00 2001 From: Roman Rudakov Date: Sat, 15 Feb 2025 20:47:26 +0100 Subject: [PATCH] Add customization option to disable markdown syntax highlighting --- CHANGELOG.md | 2 ++ README.md | 9 +++++++++ clojure-ts-mode.el | 13 ++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f0f61a..01304a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ - Fix semantic indentation of quoted functions - Add custom `fill-paragraph-function` which respects docstrings similar to `clojure-mode`. +- Add customization option to disable markdown syntax highlighting in the + docstrings. ## 0.2.2 (2024-02-16) diff --git a/README.md b/README.md index a3d762c..ca2f670 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,15 @@ To highlight entire rich `comment` expression with the comment font face, set By default this is `nil`, so that anything within a `comment` expression is highlighted like regular clojure code. +### Highlight markdown syntax in docstrings + +By default markdown syntax is highlighted in the docstrings using +`markdown_inline` grammar. To disable this feature set + +``` emacs-lisp +(setopt clojure-ts-use-markdown-inline nil) +``` + ### Navigation and Evaluation To make forms inside of `(comment ...)` forms appear as top-level forms for evaluation and navigation, set diff --git a/clojure-ts-mode.el b/clojure-ts-mode.el index 1d6fa21..10bb3f5 100644 --- a/clojure-ts-mode.el +++ b/clojure-ts-mode.el @@ -112,6 +112,12 @@ double quotes on the third column." :safe #'integerp :package-version '(clojure-ts-mode . "0.2.3")) +(defcustom clojure-ts-use-markdown-inline t + "When non-nil, use Markdown inline grammar for docstrings." + :type 'boolean + :safe #'booleanp + :package-version '(clojure-ts-mode . "0.2.3")) + (defvar clojure-ts--debug nil "Enables debugging messages, shows current node in mode-line. Only intended for use at development time.") @@ -1010,13 +1016,14 @@ See `clojure-ts--font-lock-settings' for usage of MARKDOWN-AVAILABLE." \\{clojure-ts-mode-map}" :syntax-table clojure-ts-mode-syntax-table (clojure-ts--ensure-grammars) - (let ((markdown-available (treesit-ready-p 'markdown_inline t))) - (when markdown-available + (let ((use-markdown-inline (and clojure-ts-use-markdown-inline + (treesit-ready-p 'markdown_inline t)))) + (when use-markdown-inline (treesit-parser-create 'markdown_inline) (setq-local treesit-range-settings clojure-ts--treesit-range-settings)) (when (treesit-ready-p 'clojure) (treesit-parser-create 'clojure) - (clojure-ts-mode-variables markdown-available) + (clojure-ts-mode-variables use-markdown-inline) (when clojure-ts--debug (setq-local treesit--indent-verbose t) (when (eq clojure-ts--debug 'font-lock)