diff options
Diffstat (limited to 'emmet-mode.el')
-rw-r--r-- | emmet-mode.el | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/emmet-mode.el b/emmet-mode.el index afb1fcd..fa866ae 100644 --- a/emmet-mode.el +++ b/emmet-mode.el @@ -2543,7 +2543,9 @@ tbl)) (let ((expr (car it)) (input (cdr it))) (destructuring-bind (expr . input) (emmet-tag-text expr input) - (emmet-expand-tag-alias expr input))))))) + (or + (emmet-expand-lorem expr input) + (emmet-expand-tag-alias expr input)))))))) (emmet-default-tag input))) (defun emmet-get-first-tag (expr) @@ -2555,6 +2557,21 @@ tbl)) (emmet-get-first-tag (cdr expr)))) nil)) +(defun emmet-lorem (input) + (emmet-aif + (and (stringp input) (emmet-regex "\\(?:lorem\\|ipsum\\)\\([0-9]*\\)" input '(0 1))) + (let ((w (elt it 1))) + (let ((word-num (if (string-equal w "") 30 (read w)))) + word-num)))) + +(defun emmet-expand-lorem (tag input) + (let ((tag-data (cadr tag))) + (let ((tag-name (car tag-data))) + (emmet-aif (emmet-lorem tag-name) + (if (equalp (cdr tag-data) '(t nil nil nil nil)) + `((text (lorem ,it)) . ,input) + `((tag ("div" ,@(subseq tag-data 1 -1) (lorem ,it))) . ,input)))))) + (defun emmet-expand-tag-alias (tag input) (let ((tag-data (cadr tag))) (let ((tag-name (car tag-data))) @@ -2792,11 +2809,22 @@ tbl)) "hic" (emmet-primary-filter emmet-make-hiccup-tag) "e" (emmet-escape-xml))) +(defun emmet-instantiate-lorem-expression (input) + (if input + (if (consp input) + (if (and (eql (car input) 'lorem) (numberp (cadr input))) + (emmet-lorem-generate (cadr input)) + (cons (emmet-instantiate-lorem-expression (car input)) + (emmet-instantiate-lorem-expression (cdr input)))) + input))) + (defun emmet-primary-filter (input proc) "Process filter that needs to be executed first, ie. not given output from other filter." (if (listp input) (let ((tag-maker (cadr proc))) - (emmet-transform-ast input tag-maker)) + (emmet-transform-ast + (emmet-instantiate-lorem-expression input) + tag-maker)) nil)) (defun emmet-process-filter (filters input) @@ -3161,6 +3189,7 @@ tbl)) (let ((next (emmet-lorem-generate (- count sl)))) (if (string-equal next "") "" (concat " " next)))))))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;; CSS abbrev: |