diff --git a/lib/less/functions.js b/lib/less/functions.js index 419a4ced..804b9e6f 100644 --- a/lib/less/functions.js +++ b/lib/less/functions.js @@ -128,8 +128,10 @@ tree.functions = { str = quoted.value; for (var i = 0; i < args.length; i++) { - str = str.replace(/%s/, args[i].value) - .replace(/%[da]/, args[i].toCSS()); + str = str.replace(/%[sda]/i, function(token) { + var value = token.match(/s/i) ? args[i].value : args[i].toCSS(); + return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value; + }); } str = str.replace(/%%/g, '%'); return new(tree.Quoted)('"' + str + '"', str); diff --git a/test/css/functions.css b/test/css/functions.css index d6d0ea84..f33b9869 100644 --- a/test/css/functions.css +++ b/test/css/functions.css @@ -16,6 +16,8 @@ spin-n: #bf4055; format: "rgb(32, 128, 64)"; format-string: "hello world"; + format-multiple: "hello earth 2"; + format-url-encode: "red is %23ff0000"; eformat: rgb(32, 128, 64); hue: 98; saturation: 12%; diff --git a/test/less/functions.less b/test/less/functions.less index 634a65b8..1af78bc8 100644 --- a/test/less/functions.less +++ b/test/less/functions.less @@ -19,6 +19,8 @@ spin-n: spin(hsl(30, 50%, 50%), -40); format: %("rgb(%d, %d, %d)", @r, 128, 64); format-string: %("hello %s", "world"); + format-multiple: %("hello %s %d", "earth", 2); + format-url-encode: %('red is %A', #ff0000); eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64)); hue: hue(hsl(98, 12%, 95%));