[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/jade-mode ecc1253196 111/128: Merge pull request #56 from
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/jade-mode ecc1253196 111/128: Merge pull request #56 from MC-Escherichia/fix-regexes |
Date: |
Sat, 29 Jan 2022 08:24:52 -0500 (EST) |
branch: elpa/jade-mode
commit ecc125319695b662725e6a03235306caefd973f2
Merge: efb86f6a36 ce2400711d
Author: Travis Jefferson <tjefferson@signpost.com>
Commit: Travis Jefferson <tjefferson@signpost.com>
Merge pull request #56 from MC-Escherichia/fix-regexes
Named regexes, cask integration, more tests
---
.gitignore | 1 +
Cask | 12 ++++++
Makefile | 2 +-
example.jade | 1 +
jade-mode.el | 15 +++++---
test/highlight-test.el | 25 ++++++++++++
tests/indentation.el => test/indentation-test.el | 0
test/test-helper.el | 49 ++++++++++++++++++++++++
tests/highlight.el | 33 ----------------
9 files changed, 98 insertions(+), 40 deletions(-)
diff --git a/.gitignore b/.gitignore
index c531d9867f..1304fa25e0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
*.elc
+/.cask/
diff --git a/Cask b/Cask
new file mode 100644
index 0000000000..21abb1ccf8
--- /dev/null
+++ b/Cask
@@ -0,0 +1,12 @@
+(source gnu)
+(source melpa)
+
+(package "jade-mode" "0.2.1" "Syntax hilighting and smart-tabs for jade html
language")
+
+;; (package-file "jade-mode.el")
+
+(development
+ (depends-on "f")
+ (depends-on "ecukes")
+ (depends-on "ert-runner")
+ (depends-on "el-mock"))
diff --git a/Makefile b/Makefile
index 6ba9019f9d..6d1c66ddc9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
test:
- emacs -batch -L . -l ./tests/highlight.el -l ./tests/indentation.el -f
ert-run-tests-batch-and-exit
+ cask exec ert-runner -l jade-mode.el
# Local Variables:
# indent-tabs-mode: t
diff --git a/example.jade b/example.jade
index a19782edd7..1795a304e0 100644
--- a/example.jade
+++ b/example.jade
@@ -28,6 +28,7 @@ html(lang="en", class = ['classOne', 'classTwo'].join(','))
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 ?
div#paren.content.example(style = 'float: left;') Content .here
#should be plain if for
+ +help("if this is .bolded #that's bad, we want a string","a second arg
or else");
div.examples#javascript
- var a = 1;
- var helperFunction = function (a) { return (a === 1 ? 'singular' :
'plural'); };
diff --git a/jade-mode.el b/jade-mode.el
index 16d6fbccc7..69505357fe 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -72,23 +72,26 @@
(defvar jade-class-re "[.][a-zA-Z][0-9a-zA-Z_\\-]*"
"Regexp used to match a class literal, e.g. .class, .class_name-123")
+(defvar jade-mixin-re "[+][a-zA-Z][0-9a-zA-Z_\\-]*"
+ "Regexp used to match a mixin name")
+
(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-tag-declaration-char-re "[-a-zA-Z0-9_.#]"
+(defvar jade-tag-declaration-char-re "[-a-zA-Z0-9_.#+]"
"Regexp used to match a character in a tag declaration")
(defvar jade-font-lock-keywords
`(
(,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
- ("^[ \t]*\\([a-zA-Z0-9]+\\)" 1 font-lock-function-name-face) ;; tag name
- ("^[ \t]*\\(-?//.*\\)" 1 font-lock-comment-face t) ;; jade block comments
+ (,jade-id-re . font-lock-variable-name-face) ;; id
+ (,jade-class-re . font-lock-type-face) ;; class name
+ ("\\(-?//.*\\)" 1 font-lock-comment-face t) ;; jade block comments
+ (,jade-tag-re . font-lock-function-name-face)
+ ;; tag name
;; remove highlighting from literal content following tag/class/id
;; e.g. tag Inner text
diff --git a/test/highlight-test.el b/test/highlight-test.el
new file mode 100644
index 0000000000..397faddbc3
--- /dev/null
+++ b/test/highlight-test.el
@@ -0,0 +1,25 @@
+(ert-deftest jade-mode-command-should-be-bound ()
+ (with-temp-buffer
+ (should (fboundp 'jade-mode))
+ (should (null (jade-mode)))))
+
+(ert-deftest jade-mode-highlight-doctype ()
+ (jade-test-with-temp-buffer-pt-min
+ "doctype html\n\n"
+ (should (eq (get-text-property 1 'face)
+ 'font-lock-comment-face))
+ (should (eq
+ (next-single-property-change (point) 'face)
+ (point-at-eol)))))
+
+(ert-deftest jade-mode-highlights-in-isolation ()
+ (jade-test-highlight-one-word "mixin" 'font-lock-keyword-face 2)
+
+ (jade-test-highlight-one-word "#container" 'font-lock-variable-name-face 2)
+ (jade-test-highlight-one-word ".class" 'font-lock-type-face 2)
+ (jade-test-highlight-one-word "// this is a comment" 'font-lock-comment-face
2)
+ (jade-test-highlight-one-word "//- this is a comment"
'font-lock-comment-face 2)
+ (jade-test-highlight-one-word "-// this is a comment"
'font-lock-comment-face 2)
+ (jade-test-highlight-one-word "head" 'font-lock-function-name-face 0)
+ (jade-test-highlight-one-word "body" 'font-lock-function-name-face 2)
+ (jade-test-highlight-one-word "doctype html" 'font-lock-comment-face 0))
diff --git a/tests/indentation.el b/test/indentation-test.el
similarity index 100%
rename from tests/indentation.el
rename to test/indentation-test.el
diff --git a/test/test-helper.el b/test/test-helper.el
new file mode 100644
index 0000000000..34a6c3f7a8
--- /dev/null
+++ b/test/test-helper.el
@@ -0,0 +1,49 @@
+;;; test-helper.el --- macros and functions for testing jade-mode.el based on
python-mode.el ert test-suite
+
+;; Copyright (C) 2015
+
+;; Author: <matt@Akshobya>
+
+;; test highlighting based on python mode
https://github.com/jkitchin/jmax/blob/master/python-mode/test/py-ert-tests.el
+
+(defmacro jade-test-with-temp-buffer-pt-max (contents &rest body)
+ "Creates a temp buffer in `jade-mode' inserting CONTENTS. BODY is code to be
executed within temp buffer. Point is placed at end-of-buffer"
+ (declare (indent 0) (debug t))
+ `(with-temp-buffer
+ (jade-mode)
+ (insert ,contents)
+ (font-lock-fontify-buffer)
+ ,@body))
+
+(defmacro jade-test-with-temp-buffer-pt-min (contents &rest body)
+ "Creates a temp buffer in `jade-mode' inserting CONTENTS. BODY is code to be
executed within temp buffer. Point is placed at beginning-of-buffer"
+ (declare (indent 1))
+ `(jade-test-with-temp-buffer-pt-max
+ ,contents
+ ,@(cons '(goto-char (point-min)) body)))
+
+(defun jade-test-go-to (string)
+ (and (eq (point) (point-max)) (goto-char (point-min)))
+ (search-forward string nil t 1))
+
+(defun jade-test--show-tested-text (text form)
+ form)
+
+(defmacro jade-test-highlight-one-word (word face n)
+ `(jade-test-with-temp-buffer-pt-min
+ ,(concat (s-repeat n "\t") word "\n\n")
+ (print (buffer-string))
+ (should (eq (jade-test--show-tested-text
+ ,word
+ (get-text-property
+ ,(+ 1 n) 'face))
+ ,face))
+ (goto-char ,(+ 1 n))
+ (should (eq
+ (next-single-property-change (point) 'face)
+ (point-at-eol)))))
+
+
+
+
+(byte-to-string 108)
diff --git a/tests/highlight.el b/tests/highlight.el
deleted file mode 100644
index 868d24d953..0000000000
--- a/tests/highlight.el
+++ /dev/null
@@ -1,33 +0,0 @@
-(require 'ert)
-(require 'jade-mode)
-
-(ert-deftest jade-mode-command-should-be-bound ()
- (with-temp-buffer
- (should (fboundp 'jade-mode))
- (should (null (jade-mode)))))
-
-(ert-deftest jade-mode-highlight-doctype ()
- (with-temp-buffer
-
- ;; interesting - if you omit the trailing newline in the string,
- ;; `font-lock-fontify-buffer' will freak out and fail with
- ;; end-of-buffer
- (insert "doctype html\nhtml content\n\n")
- (jade-mode)
-
- ;; temp buffers require explict fontification
- (font-lock-fontify-buffer)
-
- ;; face at char 1 should be `font-lock-comment-face'
- (should (eq
- (get-text-property 1 'face)
- 'font-lock-comment-face))
- (goto-char 1)
-
- ;; face shouldn't change (from `font-lock-comment-face') b/t char
- ;; 1 and eol
- (should (=
- (next-single-property-change (point) 'face)
- (point-at-eol)))))
-
-
- [nongnu] elpa/jade-mode 334faaa998 127/128: fix small typo, (continued)
- [nongnu] elpa/jade-mode 334faaa998 127/128: fix small typo, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode e9cc84aff7 020/128: use mark-active instead of region-active-p, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode d259953442 030/128: Change doctype facename to font-lock-comment-face., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode c2a826f61b 031/128: Change id facename to font-lock-variable-name-face., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode ed4275a1f8 047/128: Merge pull request #10 from telaviv/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 33bad1d74e 065/128: Merge pull request #28 from Sterlingg/DedentFix, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 573f954c7e 025/128: set indent-tabs-mode as nil, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 6707074e67 073/128: Merge pull request #32 from tjefferson08/20_single_quote_highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 8f2959ef79 093/128: Merge pull request #43 from tjefferson08/fix_comment_again, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode ba002b5e03 072/128: [#20] fix basic issue of single-quote highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode ecc1253196 111/128: Merge pull request #56 from MC-Escherichia/fix-regexes,
ELPA Syncer <=
- [nongnu] elpa/jade-mode cfd25bce3e 125/128: Merge pull request #70 from wasamasa/fix-mode-definition, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 111460b056 126/128: Merge pull request #71 from phikal/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 4079475e60 029/128: Modify comment for font-lock-keywords matcher., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode d2c37c960b 060/128: Merge pull request #22 from Niluge-KiWi/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 86f0734689 055/128: add init.el boilerplate for flymake support in the README, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode b33e7017f7 052/128: Defvar instead of setq, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode fd1a442556 059/128: Add missing jade keywords "block append", "block prepend", "append" and "prepend", ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 992ed1e50d 046/128: single quoted strings are now properly highlighted., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 210825fd5e 032/128: Change class facename to font-lock-type-face., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 7ff3a4cb0a 035/128: Use local variables settings already in the sws-mode., ELPA Syncer, 2022/01/29