Created
January 7, 2014 13:08
-
-
Save sharapeco/8299031 to your computer and use it in GitHub Desktop.
LESS を日本語の変数名に対応させるパッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -Naru less.orig/lib/less/parser.js less/lib/less/parser.js | |
--- less.orig/lib/less/parser.js 2014-01-02 02:36:49.000000000 +0900 | |
+++ less/lib/less/parser.js 2014-01-07 22:04:08.000000000 +0900 | |
@@ -921,7 +921,7 @@ | |
variable: function () { | |
var name, index = i; | |
- if (input.charAt(i) === '@' && (name = $re(/^@@?[\w-]+/))) { | |
+ if (input.charAt(i) === '@' && (name = $re(/^@@?[\w一-龠ぁ-んァ-ヴ-]+/))) { | |
return new(tree.Variable)(name, index, env.currentFileInfo); | |
} | |
}, | |
@@ -930,7 +930,7 @@ | |
variableCurly: function () { | |
var curly, index = i; | |
- if (input.charAt(i) === '@' && (curly = $re(/^@\{([\w-]+)\}/))) { | |
+ if (input.charAt(i) === '@' && (curly = $re(/^@\{([\w一-龠ぁ-んァ-ヴ-]+)\}/))) { | |
return new(tree.Variable)("@" + curly[1], index, env.currentFileInfo); | |
} | |
}, | |
@@ -1013,7 +1013,7 @@ | |
variable: function () { | |
var name; | |
- if (input.charAt(i) === '@' && (name = $re(/^(@[\w-]+)\s*:/))) { return name[1]; } | |
+ if (input.charAt(i) === '@' && (name = $re(/^(@[\w一-龠ぁ-んァ-ヴ-]+)\s*:/))) { return name[1]; } | |
}, | |
// | |
@@ -1920,7 +1920,7 @@ | |
} | |
match(/^(\*?)/); | |
- while (match(/^((?:[\w-]+)|(?:@\{[\w-]+\}))/)); // ! | |
+ while (match(/^((?:[\w-]+)|(?:@\{[\w一-龠ぁ-んァ-ヴ-]+\}))/)); // ! | |
if ((name.length > 1) && match(/^\s*(\+?)\s*:/)) { | |
// at last, we have the complete match now. move forward, | |
// convert @{var}s to tree.Variable(s) and return: | |
@@ -1950,4 +1950,4 @@ | |
} | |
return s; | |
-}; | |
\ No newline at end of file | |
+}; | |
diff -Naru less.orig/lib/less/tree/javascript.js less/lib/less/tree/javascript.js | |
--- less.orig/lib/less/tree/javascript.js 2014-01-02 02:36:49.000000000 +0900 | |
+++ less/lib/less/tree/javascript.js 2014-01-07 22:01:06.000000000 +0900 | |
@@ -12,7 +12,7 @@ | |
that = this, | |
context = {}; | |
- var expression = this.expression.replace(/@\{([\w-]+)\}/g, function (_, name) { | |
+ var expression = this.expression.replace(/@\{([\w一-龠ぁ-んァ-ヴ-]+)\}/g, function (_, name) { | |
return tree.jsify(new(tree.Variable)('@' + name, that.index).eval(env)); | |
}); | |
diff -Naru less.orig/lib/less/tree/quoted.js less/lib/less/tree/quoted.js | |
--- less.orig/lib/less/tree/quoted.js 2014-01-02 02:36:49.000000000 +0900 | |
+++ less/lib/less/tree/quoted.js 2014-01-07 22:01:21.000000000 +0900 | |
@@ -23,7 +23,7 @@ | |
var that = this; | |
var value = this.value.replace(/`([^`]+)`/g, function (_, exp) { | |
return new(tree.JavaScript)(exp, that.index, true).eval(env).value; | |
- }).replace(/@\{([\w-]+)\}/g, function (_, name) { | |
+ }).replace(/@\{([\w一-龠ぁ-んァ-ヴ-]+)\}/g, function (_, name) { | |
var v = new(tree.Variable)('@' + name, that.index, that.currentFileInfo).eval(env, true); | |
return (v instanceof tree.Quoted) ? v.value : v.toCSS(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment