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

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

[nongnu] elpa/jade-mode ba002b5e03 072/128: [#20] fix basic issue of sin


From: ELPA Syncer
Subject: [nongnu] elpa/jade-mode ba002b5e03 072/128: [#20] fix basic issue of single-quote highlighting
Date: Sat, 29 Jan 2022 08:24:48 -0500 (EST)

branch: elpa/jade-mode
commit ba002b5e03d9d928d4c3709a909ecccd303dd11a
Author: Travis Jefferson <tjefferson@signpost.com>
Commit: Travis Jefferson <tjefferson@signpost.com>

    [#20] fix basic issue of single-quote highlighting
    
        1. Unrelated, but fix comments to fontify content only, not any
           leading whitespace (some faces will change whitespace width)
    
        2. Highlight single-quote string literals after lines that open
           with an equals sign (=). There is room to improve here; we'd
           like this behavior in other scenarios, but let's just fix the
           issue for now.
    
        3. Remove higlighting from lines which open with a pipe (|)
---
 jade-mode.el | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

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]