emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/jade-mode 6707074e67 073/128: Merge pull request #32 from


From: ELPA Syncer
Subject: [nongnu] elpa/jade-mode 6707074e67 073/128: Merge pull request #32 from tjefferson08/20_single_quote_highlighting
Date: Sat, 29 Jan 2022 08:24:48 -0500 (EST)

branch: elpa/jade-mode
commit 6707074e67bb4ce81734b14d172a6be91c2b7bde
Merge: ae579601b8 ba002b5e03
Author: Brian C <brian.m.carlson@gmail.com>
Commit: Brian C <brian.m.carlson@gmail.com>

    Merge pull request #32 from tjefferson08/20_single_quote_highlighting
    
    Issue #20 - single quote highlighting
---
 example.jade |  5 +++++
 jade-mode.el | 31 ++++++++++++++++++++++++++++---
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/example.jade b/example.jade
index 7ed94916d7..ba438263e6 100644
--- a/example.jade
+++ b/example.jade
@@ -18,6 +18,11 @@ html(lang="en")
           p Get on it!
           form
             input(type: "text", name='user[name]', readonly: true, disabled)
+        div#single-quote.example
+          = 'this single quote should highlight as a string'
+          = 'this one' + "and this should too"
+          span this one shouldn't higlight strings or... .other #things if else
+          | this one shouldn't highlight strings, and the same goes for 
.keywords #ok ?
       #footer
         #copywrite-text= locals
 
diff --git a/jade-mode.el b/jade-mode.el
index e4463a2b80..da0d3c193d 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -40,19 +40,44 @@ For detail, see `comment-dwim'."
        "include" "yield" "mixin") 'words))
   "Jade keywords.")
 
+(defvar jade-double-quote-string-re "[\"]\\(\\\\.\\|[^\"\n]\\)*[\"]"
+  "Regexp used to match a double-quoted string literal")
+
+(defvar jade-single-quote-string-re "[']\\(\\\\.\\|[^'\n]\\)*[']"
+  "Regexp used to match a single-quoted string literal")
+
 (defvar jade-font-lock-keywords
-  `((,"!!!\\|doctype\\( ?[A-Za-z0-9\-\_]*\\)?" 0 font-lock-comment-face) ;; 
doctype
+  `(
+    ;; higlight string literals on lines beginning with an equals sign
+    ;; TODO improve this to play nice with attribute assignments in
+    ;; parentheses following tags
+    (,(concat "^\\s-*"
+              "=")
+              (,(concat jade-single-quote-string-re "\\|" 
jade-double-quote-string-re)
+               nil
+               nil
+               (0 font-lock-string-face)))
+
+    (,"!!!\\|doctype\\( ?[A-Za-z0-9\-\_]*\\)?" 0 font-lock-comment-face) ;; 
doctype
     (,jade-keywords . font-lock-keyword-face) ;; keywords
     (,"#\\(\\w\\|_\\|-\\)*" . font-lock-variable-name-face) ;; id
     (,"\\(?:^[ {2,}]*\\(?:[a-z0-9_:\\-]*\\)\\)?\\(#[A-Za-z0-9\-\_]*[^ ]\\)" 1 
font-lock-variable-name-face) ;; id
     (,"\\(?:^[ {2,}]*\\(?:[a-z0-9_:\\-]*\\)\\)?\\(\\.[A-Za-z0-9\-\_]*\\)" 1 
font-lock-type-face) ;; class name
     (,"^[ {2,}]*[a-z0-9_:\\-]*" 0 font-lock-function-name-face) ;; tag name
-    (,"^\\s-*//.*" 0 font-lock-comment-face t))) ;; jade block comments
+    (,"^\\s-*\\(//.*\\)" 1 font-lock-comment-face t) ;; jade block comments
+
+    ;; remove highlighting from lines opening with a pipe `|'
+    ;; e.g. | keywords like for should not be highlighted here
+    ;;      | I'm not supposed to highlight single quotes either
+    (,(concat "^\\s-*"
+              "\\("
+              "|"
+              ".*"
+              "\\)") 1 nil t)))
 
 ;; syntax table
 (defvar jade-syntax-table
   (let ((syn-table (make-syntax-table)))
-    (modify-syntax-entry ?' "\"" syn-table)
     syn-table)
   "Syntax table for `jade-mode'.")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]