Skip to content

quick fix for != syntax #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions example.jade
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ html(lang="en", class = ['classOne', 'classTwo'].join(','))
div#single-quote.example
= 'this single quote should highlight as a string'
= 'this one' + "and this should too"
!= 'unescaped example'
span= 'another' + "quote example"
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 ?
Expand All @@ -35,6 +36,7 @@ html(lang="en", class = ['classOne', 'classTwo'].join(','))
- var helperFunction = function (a) { return (a === 1 ? 'singular' : 'plural'); };
span= someArray.join(', ')
span= a.toString() + helperFunction(a)
span!= a.toString() + helperFunction(a)
span#id.class(style = 'margin-bottom: 0;')= "some_js_expression".split('_').join(' ')
#footer
#copywrite-text= locals
Expand Down
10 changes: 8 additions & 2 deletions jade-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,24 @@ javascript."

;; before parsing/skipping ahead, check the first char; if it's
;; - (not a comment starter!) or =, then we know it's a JS block
(if (or (looking-at "-[^/]") (looking-at "="))
(if (or (looking-at "-[^/]") (looking-at "[!]?="))
(jade-fontify-region-as-js (point) (point-at-eol))

;; no luck with the first char, so parse to the end of the tag
;; (including optional paren block) and check for '='
(jade-goto-end-of-tag)
(if (and (looking-at "=") (not (eolp)))
(if (and (looking-at "[!]?=") (not (eolp)))
(jade-fontify-region-as-js (point) (point-at-eol)))))

;; return some empty match data to appease the font-lock gods
(looking-at "\\(\\)")))

(defun reload-jade-mode ()
(interactive)
(when (fboundp 'jade-mode)
(unload-feature 'jade-mode))
(eval-buffer "jade-mode.el"))

(defun jade-goto-end-of-tag ()
"Skip ahead over whitespace, tag characters (defined in
`jade-tag-declaration-char-re'), and paren blocks (using
Expand Down