aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam David Mayo ("Dave") <pobocks@gmail.com>2015-04-10 11:03:50 -0400
committerWilliam David Mayo ("Dave") <pobocks@gmail.com>2015-04-10 11:03:50 -0400
commit983ad460dede6b3cbcf771321dc2fcf5851f6404 (patch)
treea91a47c945c568f471fbedf6d77497635467284e
parent9324673829f97baacfd5db156a39c08903910ed5 (diff)
parent69e97b001744d4e227384e5f3e8078b17ccf744c (diff)
downloademmet-mode-983ad460dede6b3cbcf771321dc2fcf5851f6404.tar.lz
emmet-mode-983ad460dede6b3cbcf771321dc2fcf5851f6404.tar.xz
emmet-mode-983ad460dede6b3cbcf771321dc2fcf5851f6404.zip
Merge pull request #62 from smihica/issue_61
Refs #61 - Escape using backslash inside { text }
-rw-r--r--README.md2
-rw-r--r--emmet-mode.el17
-rw-r--r--src/html-abbrev.el11
-rw-r--r--src/mode-def.el6
-rw-r--r--src/test.el2
5 files changed, 26 insertions, 12 deletions
diff --git a/README.md b/README.md
index f8acc82..4abf11b 100644
--- a/README.md
+++ b/README.md
@@ -347,6 +347,8 @@ you'll transform your snippet into the appropriate tag structure.
</p>
<span>here</span>
to continue
+ p{\{Escape brackets!\} and \\}
+ <p>{Escape brackets} and \</p>
#### Lorem-Ipsum generator
diff --git a/emmet-mode.el b/emmet-mode.el
index a76c37e..33a7b42 100644
--- a/emmet-mode.el
+++ b/emmet-mode.el
@@ -172,12 +172,14 @@ and leaving the point in place."
"Find the left bound of an emmet expr"
(save-excursion (save-match-data
(let ((char (char-before))
- (in-style-attr (looking-back "style=[\"'][^\"']*")))
+ (in-style-attr (looking-back "style=[\"'][^\"']*"))
+ (syn-tab (make-syntax-table)))
+ (modify-syntax-entry ?\\ "\\")
(while char
(cond ((and in-style-attr (member char '(?\" ?\')))
(setq char nil))
((member char '(?\} ?\] ?\)))
- (with-syntax-table (standard-syntax-table)
+ (with-syntax-table syn-tab
(backward-sexp) (setq char (char-before))))
((eq char ?\>)
(if (looking-back "<[^>]+>" (line-beginning-position))
@@ -3181,9 +3183,12 @@ tbl))
(defun emmet-text (input)
"A zen coding expression innertext."
- (emmet-parse "{\\(.*?\\)}" 2 "inner text"
- (let ((txt (emmet-split-numbering-expressions (elt it 1))))
- `((text ,txt) . ,input))))
+ (emmet-parse "{\\(\\(?:\\\\.\\|[^\\\\}]\\)*?\\)}" 2 "inner text"
+ (let ((txt (emmet-split-numbering-expressions (elt it 1))))
+ (if (listp txt)
+ (setq txt (cons (car txt) (cons (replace-regexp-in-string "\\\\\\(.\\)" "\\1" (cadr txt)) (cddr txt))))
+ (setq txt (replace-regexp-in-string "\\\\\\(.\\)" "\\1" txt)))
+ `((text ,txt) . ,input))))
(defun emmet-properties (input)
"A bracketed emmet property expression."
@@ -3462,7 +3467,7 @@ tbl))
(if self-closing? "/>"
(concat ">"
(if tag-txt
- (if block-indentation?
+ (if block-indentation?
(emmet-indent tag-txt)
tag-txt))
(if content
diff --git a/src/html-abbrev.el b/src/html-abbrev.el
index 0c3519b..961ee16 100644
--- a/src/html-abbrev.el
+++ b/src/html-abbrev.el
@@ -287,9 +287,12 @@
(defun emmet-text (input)
"A zen coding expression innertext."
- (emmet-parse "{\\(.*?\\)}" 2 "inner text"
- (let ((txt (emmet-split-numbering-expressions (elt it 1))))
- `((text ,txt) . ,input))))
+ (emmet-parse "{\\(\\(?:\\\\.\\|[^\\\\}]\\)*?\\)}" 2 "inner text"
+ (let ((txt (emmet-split-numbering-expressions (elt it 1))))
+ (if (listp txt)
+ (setq txt (cons (car txt) (cons (replace-regexp-in-string "\\\\\\(.\\)" "\\1" (cadr txt)) (cddr txt))))
+ (setq txt (replace-regexp-in-string "\\\\\\(.\\)" "\\1" txt)))
+ `((text ,txt) . ,input))))
(defun emmet-properties (input)
"A bracketed emmet property expression."
@@ -568,7 +571,7 @@
(if self-closing? "/>"
(concat ">"
(if tag-txt
- (if block-indentation?
+ (if block-indentation?
(emmet-indent tag-txt)
tag-txt))
(if content
diff --git a/src/mode-def.el b/src/mode-def.el
index 0181baa..2bba6ec 100644
--- a/src/mode-def.el
+++ b/src/mode-def.el
@@ -19,12 +19,14 @@
"Find the left bound of an emmet expr"
(save-excursion (save-match-data
(let ((char (char-before))
- (in-style-attr (looking-back "style=[\"'][^\"']*")))
+ (in-style-attr (looking-back "style=[\"'][^\"']*"))
+ (syn-tab (make-syntax-table)))
+ (modify-syntax-entry ?\\ "\\")
(while char
(cond ((and in-style-attr (member char '(?\" ?\')))
(setq char nil))
((member char '(?\} ?\] ?\)))
- (with-syntax-table (standard-syntax-table)
+ (with-syntax-table syn-tab
(backward-sexp) (setq char (char-before))))
((eq char ?\>)
(if (looking-back "<[^>]+>" (line-beginning-position))
diff --git a/src/test.el b/src/test.el
index 75398af..68e50ab 100644
--- a/src/test.el
+++ b/src/test.el
@@ -670,6 +670,8 @@
#'emmet-regression-54-test
'((("span.whut[thing=\"stuff\"]{Huh?}") . "<div class=\"broken\"><span class=\"whut\" thing=\"stuff\">Huh?</span>")))
+(define-emmet-transform-html-test-case regression-61-bracket-escapes
+ "div{\\}\\}\\}}" ("<div>}}}</div>"))
;; start
(emmet-test-cases)