diff options
Diffstat (limited to 'src/mode-def.el')
-rw-r--r-- | src/mode-def.el | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/mode-def.el b/src/mode-def.el index f9a3795..4dd1e56 100644 --- a/src/mode-def.el +++ b/src/mode-def.el @@ -10,18 +10,21 @@ for the current line." (let* ((end (point)) (start (emmet-find-left-bound)) - (line (buffer-substring-no-properties start end))) - (let ((expr (emmet-regex "\\([ \t]*\\)\\([^\n]+\\)" line 2))) - (if (first expr) - (list (first expr) start end))))) + (line (buffer-substring-no-properties start end)) + (expr (emmet-regex "\\([ \t]*\\)\\([^\n]+\\)" line 2))) + (if (first expr) + (list (first expr) start end)))) (defun emmet-find-left-bound () "Find the left bound of an emmet expr" (save-excursion (save-match-data (let ((char (char-before)) - (last-gt (point))) + (last-gt (point)) + (in-style-attr (looking-back "style=\"[^\"]*"))) (while char - (cond ((member char '(?\} ?\] ?\))) + (cond ((and in-style-attr (eq char ?\")) + (setq char nil)) + ((member char '(?\} ?\] ?\))) (backward-sexp) (setq char (char-before))) ((eq char ?\>) (setq last-gt (point)) (backward-char) (setq char (char-before))) @@ -61,7 +64,7 @@ e. g. without semicolons") "Major modes that use emmet for CSS, rather than HTML.") (defun emmet-transform (input) - (if emmet-use-css-transform + (if (or (emmet-detect-style-tag-and-attr) emmet-use-css-transform) (emmet-css-transform input) (emmet-html-transform input))) @@ -76,6 +79,16 @@ e. g. without semicolons") (+ (- p (length output-markup)) new-pos)))))) +(defun emmet-detect-style-tag-and-attr () + (let* ((qt "\"") + (not-qt (format "[^%s]" qt)) + (everything "\\(.\\|\n\\)*")) + (or + (and (looking-at (format "%s*%s" not-qt qt)) + (looking-back (format "style=%s%s*" qt not-qt))) ; style attr + (and (looking-at (format "%s</style>" everything)) + (looking-back (format "<style>%s" everything)))))) ; style tag + ;;;###autoload (defun emmet-expand-line (arg) "Replace the current line's emmet expression with the corresponding expansion. |