branch: elpa/adoc-mode
commit badff4d2b06b33bb4065f96c62e7aabb1b76bd5a
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Add font-lock support for Asciidoctor inline macros
    
    Add highlighting for kbd:[], btn:[], menu:[] (UI macros) and
    pass:[], stem:[], latexmath:[], asciimath:[] (passthrough macros).
    These are commonly used Asciidoctor extensions that were previously
    only handled by the generic catch-all inline macro pattern.
---
 CHANGELOG.md           |  1 +
 adoc-mode.el           | 14 +++++++++++++-
 test/adoc-mode-test.el | 11 +++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 52ea2fb09d..34c6fdaa4b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
 
 - [#21](https://github.com/bbatsov/adoc-mode/pull/21): Add support for native 
font-locking in code blocks.
 - [#48](https://github.com/bbatsov/adoc-mode/pull/48): Add support for 
displaying images.
+- Add font-lock support for Asciidoctor inline macros: `kbd:[]`, `btn:[]`, 
`menu:[]`, `pass:[]`, `stem:[]`, `latexmath:[]`, `asciimath:[]`.
 
 ### Changes
 
diff --git a/adoc-mode.el b/adoc-mode.el
index 390ba2424f..966bd4e460 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -2522,9 +2522,21 @@ Use this function as matching function MATCHER in 
`font-lock-keywords'."
    (adoc-kw-inline-macro "footnoteref" t 'single-attribute nil nil nil
                          '(("id") (("id" . adoc-internal-reference-face))))
    (adoc-kw-inline-macro "footnoteref" t nil nil nil nil '("id" "text"))
+
+   ;; Asciidoctor UI macros
+   (adoc-kw-inline-macro "kbd" t nil adoc-command-face nil t)
+   (adoc-kw-inline-macro "btn" t nil adoc-command-face nil t)
+   (adoc-kw-inline-macro "menu" nil nil adoc-command-face nil t)
+
+   ;; Passthrough inline macros
+   (adoc-kw-inline-macro "pass" nil nil nil nil t)
+   (adoc-kw-inline-macro "stem" nil nil nil nil t)
+   (adoc-kw-inline-macro "latexmath" nil nil nil nil t)
+   (adoc-kw-inline-macro "asciimath" nil nil nil nil t)
+
    (adoc-kw-standalone-urls)
 
-   ;; Macros using default syntax and having default highlighting in adoc-mod
+   ;; Macros using default syntax and having default highlighting in adoc-mode
    (adoc-kw-inline-macro)
 
    ;; bibliographic anchor ala [[[id]]]
diff --git a/test/adoc-mode-test.el b/test/adoc-mode-test.el
index 66298077b9..a62d60728e 100644
--- a/test/adoc-mode-test.el
+++ b/test/adoc-mode-test.el
@@ -714,6 +714,17 @@ Don't use it for anything real.")
   (adoctest-faces "inline-macros"
                   "commandname" adoc-command-face ":target[" adoc-meta-face 
"attribute list" adoc-value-face "]" adoc-meta-face))
 
+(ert-deftest adoctest-test-asciidoctor-inline-macros ()
+  ;; kbd macro
+  (adoctest-faces "asciidoctor-kbd-macro"
+                  "Press " nil "kbd" adoc-command-face ":[" adoc-meta-face 
"Ctrl+C" adoc-value-face "]" adoc-meta-face)
+  ;; btn macro
+  (adoctest-faces "asciidoctor-btn-macro"
+                  "Click " nil "btn" adoc-command-face ":[" adoc-meta-face 
"OK" adoc-value-face "]" adoc-meta-face)
+  ;; pass macro
+  (adoctest-faces "asciidoctor-pass-macro"
+                  "Use " nil "pass" adoc-command-face ":[" adoc-meta-face "raw 
content" adoc-value-face "]" adoc-meta-face))
+
 (ert-deftest adoctest-test-meta-face-cleanup ()
   ;; begin with a few simple explicit cases which are easier to debug in case 
of troubles
 

Reply via email to