allowing more flexible whitespace-started regexes. You have to wrap 'em in parens or assign to 'em, but it's better than nothing.
This commit is contained in:
parent
083500fc0e
commit
1eebbfe2bc
|
@ -191,8 +191,11 @@
|
|||
return true;
|
||||
};
|
||||
Lexer.prototype.regexToken = function() {
|
||||
var end, flags, regex, str;
|
||||
if (!(this.chunk.match(REGEX_START))) {
|
||||
var _d, end, first, flags, regex, str;
|
||||
if (!(first = this.chunk.match(REGEX_START))) {
|
||||
return false;
|
||||
}
|
||||
if (first[1] === ' ' && !('CALL_START' === (_d = this.tag()) || '=' === _d)) {
|
||||
return false;
|
||||
}
|
||||
if (include(NOT_REGEX, this.tag())) {
|
||||
|
@ -606,7 +609,7 @@
|
|||
MULTI_DENT = /^((\n([ \t]*))+)(\.)?/;
|
||||
LAST_DENTS = /\n([ \t]*)/g;
|
||||
LAST_DENT = /\n([ \t]*)/;
|
||||
REGEX_START = /^\/[^\/ ]/;
|
||||
REGEX_START = /^\/([^\/])/;
|
||||
REGEX_INTERPOLATION = /([^\\]#\{.*[^\\]\})/;
|
||||
REGEX_END = /^(([imgy]{1,4})\b|\W|$)/;
|
||||
REGEX_ESCAPE = /\\[^\$]/g;
|
||||
|
|
|
@ -163,7 +163,8 @@ exports.Lexer = class Lexer
|
|||
# JavaScript and Ruby, borrow slash balancing from `@balancedToken`, and
|
||||
# borrow interpolation from `@interpolateString`.
|
||||
regexToken: ->
|
||||
return false unless @chunk.match REGEX_START
|
||||
return false unless first = @chunk.match REGEX_START
|
||||
return false if first[1] is ' ' and @tag() not in ['CALL_START', '=']
|
||||
return false if include NOT_REGEX, @tag()
|
||||
return false unless regex = @balancedToken ['/', '/']
|
||||
return false unless end = @chunk.substr(regex.length).match REGEX_END
|
||||
|
@ -527,7 +528,7 @@ LAST_DENTS = /\n([ \t]*)/g
|
|||
LAST_DENT = /\n([ \t]*)/
|
||||
|
||||
# Regex-matching-regexes.
|
||||
REGEX_START = /^\/[^\/ ]/
|
||||
REGEX_START = /^\/([^\/])/
|
||||
REGEX_INTERPOLATION = /([^\\]#\{.*[^\\]\})/
|
||||
REGEX_END = /^(([imgy]{1,4})\b|\W|$)/
|
||||
REGEX_ESCAPE = /\\[^\$]/g
|
||||
|
|
|
@ -20,4 +20,9 @@ obj = {
|
|||
}
|
||||
id = 2
|
||||
|
||||
ok ' '.match(/ /)[0] is ' '
|
||||
|
||||
regexp = / /
|
||||
ok ' '.match regexp
|
||||
|
||||
ok (obj.width()/id - obj.height()/id) is -5
|
||||
|
|
Loading…
Reference in New Issue