sassc 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/ext/libsass/Makefile +10 -6
- data/ext/libsass/Readme.md +4 -4
- data/ext/libsass/appveyor.yml +16 -1
- data/ext/libsass/docs/README.md +1 -1
- data/ext/libsass/docs/api-context-example.md +1 -1
- data/ext/libsass/docs/api-context.md +1 -1
- data/ext/libsass/docs/api-doc.md +1 -1
- data/ext/libsass/docs/api-function-example.md +12 -3
- data/ext/libsass/docs/api-function-internal.md +4 -4
- data/ext/libsass/docs/api-function.md +15 -13
- data/ext/libsass/docs/api-importer-internal.md +9 -4
- data/ext/libsass/docs/api-value.md +1 -1
- data/ext/libsass/docs/build-shared-library.md +3 -3
- data/ext/libsass/docs/custom-functions-internal.md +1 -1
- data/ext/libsass/docs/{plugins.go → plugins.md} +0 -0
- data/ext/libsass/script/ci-build-libsass +25 -36
- data/ext/libsass/script/ci-install-deps +3 -8
- data/ext/libsass/script/ci-report-coverage +17 -13
- data/ext/libsass/src/ast.cpp +102 -7
- data/ext/libsass/src/ast.hpp +53 -27
- data/ext/libsass/src/ast_def_macros.hpp +8 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +3 -2
- data/ext/libsass/src/backtrace.hpp +1 -1
- data/ext/libsass/src/bind.cpp +28 -17
- data/ext/libsass/src/bind.hpp +1 -1
- data/ext/libsass/src/context.cpp +441 -184
- data/ext/libsass/src/context.hpp +79 -82
- data/ext/libsass/src/debugger.hpp +3 -1
- data/ext/libsass/src/emitter.cpp +18 -17
- data/ext/libsass/src/emitter.hpp +5 -2
- data/ext/libsass/src/error_handling.cpp +78 -7
- data/ext/libsass/src/error_handling.hpp +50 -9
- data/ext/libsass/src/eval.cpp +100 -36
- data/ext/libsass/src/eval.hpp +5 -5
- data/ext/libsass/src/expand.cpp +32 -3
- data/ext/libsass/src/extend.cpp +1 -1
- data/ext/libsass/src/file.cpp +39 -27
- data/ext/libsass/src/file.hpp +67 -13
- data/ext/libsass/src/functions.cpp +39 -32
- data/ext/libsass/src/inspect.cpp +21 -21
- data/ext/libsass/src/json.cpp +1 -1
- data/ext/libsass/src/lexer.hpp +33 -4
- data/ext/libsass/src/output.cpp +11 -11
- data/ext/libsass/src/parser.cpp +28 -130
- data/ext/libsass/src/parser.hpp +0 -4
- data/ext/libsass/src/prelexer.cpp +8 -5
- data/ext/libsass/src/prelexer.hpp +1 -3
- data/ext/libsass/src/sass_context.cpp +52 -241
- data/ext/libsass/src/sass_context.hpp +156 -0
- data/ext/libsass/src/sass_functions.cpp +1 -26
- data/ext/libsass/src/sass_functions.hpp +32 -0
- data/ext/libsass/src/sass_interface.cpp +14 -48
- data/ext/libsass/src/sass_values.cpp +3 -77
- data/ext/libsass/src/sass_values.hpp +81 -0
- data/ext/libsass/src/source_map.cpp +7 -7
- data/ext/libsass/src/source_map.hpp +1 -4
- data/ext/libsass/src/to_string.cpp +4 -3
- data/ext/libsass/src/to_string.hpp +2 -1
- data/ext/libsass/src/util.cpp +34 -16
- data/ext/libsass/src/util.hpp +10 -8
- data/lib/sassc/version.rb +1 -1
- data/lib/tasks/libsass.rb +1 -1
- data/test/custom_importer_test.rb +6 -4
- data/test/engine_test.rb +5 -3
- data/test/functions_test.rb +1 -0
- data/test/native_test.rb +1 -1
- metadata +6 -4
- data/ext/libsass/script/coveralls-debug +0 -32
data/ext/libsass/src/extend.cpp
CHANGED
@@ -1751,7 +1751,7 @@ namespace Sass {
|
|
1751
1751
|
std::stringstream err;
|
1752
1752
|
std::string cwd(Sass::File::get_cwd());
|
1753
1753
|
ParserState pstate(ext.second->pstate());
|
1754
|
-
std::string rel_path(Sass::File::
|
1754
|
+
std::string rel_path(Sass::File::abs2rel(pstate.path, cwd, cwd));
|
1755
1755
|
err << "You may not @extend an outer selector from within @media.\n";
|
1756
1756
|
err << "You may only @extend selectors within the same directive.\n";
|
1757
1757
|
err << "From \"@extend " << ext.second->perform(&to_string) << "\"";
|
data/ext/libsass/src/file.cpp
CHANGED
@@ -126,7 +126,7 @@ namespace Sass {
|
|
126
126
|
else return path.substr(pos+1);
|
127
127
|
}
|
128
128
|
|
129
|
-
// do a
|
129
|
+
// do a logical clean up of the path
|
130
130
|
// no physical check on the filesystem
|
131
131
|
std::string make_canonical_path (std::string path)
|
132
132
|
{
|
@@ -192,59 +192,71 @@ namespace Sass {
|
|
192
192
|
return l + r;
|
193
193
|
}
|
194
194
|
|
195
|
+
std::string path_for_console(const std::string& rel_path, const std::string& abs_path, const std::string& orig_path)
|
196
|
+
{
|
197
|
+
// magic algorith goes here!!
|
198
|
+
|
199
|
+
// if the file is outside this directory show the absolute path
|
200
|
+
if (rel_path.substr(0, 3) == "../") {
|
201
|
+
return orig_path;
|
202
|
+
}
|
203
|
+
// this seems to work most of the time
|
204
|
+
return abs_path == orig_path ? abs_path : rel_path;
|
205
|
+
}
|
206
|
+
|
195
207
|
// create an absolute path by resolving relative paths with cwd
|
196
|
-
std::string
|
208
|
+
std::string rel2abs(const std::string& path, const std::string& base, const std::string& cwd)
|
197
209
|
{
|
198
|
-
return make_canonical_path((
|
210
|
+
return make_canonical_path(join_paths(join_paths(cwd, base), path));
|
199
211
|
}
|
200
212
|
|
201
213
|
// create a path that is relative to the given base directory
|
202
214
|
// path and base will first be resolved against cwd to make them absolute
|
203
|
-
std::string
|
215
|
+
std::string abs2rel(const std::string& path, const std::string& base, const std::string& cwd)
|
204
216
|
{
|
205
217
|
|
206
|
-
std::string
|
207
|
-
std::string
|
218
|
+
std::string abs_path = rel2abs(path, cwd);
|
219
|
+
std::string abs_base = rel2abs(base, cwd);
|
208
220
|
|
209
221
|
size_t proto = 0;
|
210
222
|
// check if we have a protocol
|
211
|
-
if (
|
223
|
+
if (path[proto] && Prelexer::is_alpha(path[proto])) {
|
212
224
|
// skip over all alphanumeric characters
|
213
|
-
while (
|
225
|
+
while (path[proto] && Prelexer::is_alnum(path[proto++])) {}
|
214
226
|
// then skip over the mandatory colon
|
215
|
-
if (proto &&
|
227
|
+
if (proto && path[proto] == ':') ++ proto;
|
216
228
|
}
|
217
229
|
|
218
230
|
// distinguish between windows absolute paths and valid protocols
|
219
231
|
// we assume that protocols must at least have two chars to be valid
|
220
|
-
if (proto &&
|
232
|
+
if (proto && path[proto++] == '/' && proto > 3) return path;
|
221
233
|
|
222
234
|
#ifdef _WIN32
|
223
235
|
// absolute link must have a drive letter, and we know that we
|
224
236
|
// can only create relative links if both are on the same drive
|
225
|
-
if (
|
237
|
+
if (abs_base[0] != abs_path[0]) return abs_path;
|
226
238
|
#endif
|
227
239
|
|
228
240
|
std::string stripped_uri = "";
|
229
241
|
std::string stripped_base = "";
|
230
242
|
|
231
243
|
size_t index = 0;
|
232
|
-
size_t minSize = std::min(
|
244
|
+
size_t minSize = std::min(abs_path.size(), abs_base.size());
|
233
245
|
for (size_t i = 0; i < minSize; ++i) {
|
234
246
|
#ifdef FS_CASE_SENSITIVE
|
235
|
-
if (
|
247
|
+
if (abs_path[i] != abs_base[i]) break;
|
236
248
|
#else
|
237
249
|
// compare the charactes in a case insensitive manner
|
238
250
|
// windows fs is only case insensitive in ascii ranges
|
239
|
-
if (tolower(
|
251
|
+
if (tolower(abs_path[i]) != tolower(abs_base[i])) break;
|
240
252
|
#endif
|
241
|
-
if (
|
253
|
+
if (abs_path[i] == '/') index = i + 1;
|
242
254
|
}
|
243
|
-
for (size_t i = index; i <
|
244
|
-
stripped_uri +=
|
255
|
+
for (size_t i = index; i < abs_path.size(); ++i) {
|
256
|
+
stripped_uri += abs_path[i];
|
245
257
|
}
|
246
|
-
for (size_t i = index; i <
|
247
|
-
stripped_base +=
|
258
|
+
for (size_t i = index; i < abs_base.size(); ++i) {
|
259
|
+
stripped_base += abs_base[i];
|
248
260
|
}
|
249
261
|
|
250
262
|
size_t left = 0;
|
@@ -278,7 +290,7 @@ namespace Sass {
|
|
278
290
|
// (2) underscore + given
|
279
291
|
// (3) underscore + given + extension
|
280
292
|
// (4) given + extension
|
281
|
-
std::vector<
|
293
|
+
std::vector<Include> resolve_includes(const std::string& root, const std::string& file)
|
282
294
|
{
|
283
295
|
std::string filename = join_paths(root, file);
|
284
296
|
// supported extensions
|
@@ -288,29 +300,29 @@ namespace Sass {
|
|
288
300
|
// split the filename
|
289
301
|
std::string base(dir_name(file));
|
290
302
|
std::string name(base_name(file));
|
291
|
-
std::vector<
|
303
|
+
std::vector<Include> includes;
|
292
304
|
// create full path (maybe relative)
|
293
305
|
std::string rel_path(join_paths(base, name));
|
294
306
|
std::string abs_path(join_paths(root, rel_path));
|
295
|
-
if (file_exists(abs_path))
|
307
|
+
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
|
296
308
|
// next test variation with underscore
|
297
309
|
rel_path = join_paths(base, "_" + name);
|
298
310
|
abs_path = join_paths(root, rel_path);
|
299
|
-
if (file_exists(abs_path))
|
311
|
+
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
|
300
312
|
// next test exts plus underscore
|
301
313
|
for(auto ext : exts) {
|
302
314
|
rel_path = join_paths(base, "_" + name + ext);
|
303
315
|
abs_path = join_paths(root, rel_path);
|
304
|
-
if (file_exists(abs_path))
|
316
|
+
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
|
305
317
|
}
|
306
318
|
// next test plain name with exts
|
307
319
|
for(auto ext : exts) {
|
308
320
|
rel_path = join_paths(base, name + ext);
|
309
321
|
abs_path = join_paths(root, rel_path);
|
310
|
-
if (file_exists(abs_path))
|
322
|
+
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
|
311
323
|
}
|
312
324
|
// nothing found
|
313
|
-
return
|
325
|
+
return includes;
|
314
326
|
}
|
315
327
|
|
316
328
|
// helper function to resolve a filename
|
@@ -319,7 +331,7 @@ namespace Sass {
|
|
319
331
|
// search in every include path for a match
|
320
332
|
for (size_t i = 0, S = paths.size(); i < S; ++i)
|
321
333
|
{
|
322
|
-
std::vector<
|
334
|
+
std::vector<Include> resolved(resolve_includes(paths[i], file));
|
323
335
|
if (resolved.size()) return resolved[0].abs_path;
|
324
336
|
}
|
325
337
|
// nothing found
|
data/ext/libsass/src/file.hpp
CHANGED
@@ -6,16 +6,9 @@
|
|
6
6
|
|
7
7
|
namespace Sass {
|
8
8
|
|
9
|
+
class Block;
|
9
10
|
class Context;
|
10
11
|
|
11
|
-
struct Sass_Queued {
|
12
|
-
std::string abs_path;
|
13
|
-
std::string load_path;
|
14
|
-
const char* source;
|
15
|
-
public:
|
16
|
-
Sass_Queued(const std::string& load_path, const std::string& abs_path, const char* source);
|
17
|
-
};
|
18
|
-
|
19
12
|
namespace File {
|
20
13
|
|
21
14
|
// return the current directory
|
@@ -43,15 +36,16 @@ namespace Sass {
|
|
43
36
|
// but only if right side is not absolute yet
|
44
37
|
std::string join_paths(std::string root, std::string name);
|
45
38
|
|
39
|
+
// if the relative path is outside of the cwd we want want to
|
40
|
+
// show the absolute path in console messages
|
41
|
+
std::string path_for_console(const std::string& rel_path, const std::string& abs_path, const std::string& orig_path);
|
42
|
+
|
46
43
|
// create an absolute path by resolving relative paths with cwd
|
47
|
-
std::string
|
44
|
+
std::string rel2abs(const std::string& path, const std::string& base = ".", const std::string& cwd = get_cwd());
|
48
45
|
|
49
46
|
// create a path that is relative to the given base directory
|
50
47
|
// path and base will first be resolved against cwd to make them absolute
|
51
|
-
std::string
|
52
|
-
|
53
|
-
// try to find/resolve the filename
|
54
|
-
std::vector<Sass_Queued> resolve_file(const std::string& root, const std::string& file);
|
48
|
+
std::string abs2rel(const std::string& path, const std::string& base = ".", const std::string& cwd = get_cwd());
|
55
49
|
|
56
50
|
// helper function to resolve a filename
|
57
51
|
std::string find_file(const std::string& file, const std::vector<std::string> paths);
|
@@ -64,6 +58,66 @@ namespace Sass {
|
|
64
58
|
char* read_file(const std::string& file);
|
65
59
|
|
66
60
|
}
|
61
|
+
|
62
|
+
// requested import
|
63
|
+
class Importer {
|
64
|
+
public:
|
65
|
+
// requested import path
|
66
|
+
std::string imp_path;
|
67
|
+
// parent context path
|
68
|
+
std::string ctx_path;
|
69
|
+
// base derived from context path
|
70
|
+
// this really just acts as a cache
|
71
|
+
std::string base_path;
|
72
|
+
public:
|
73
|
+
Importer(std::string imp_path, std::string ctx_path)
|
74
|
+
: imp_path(File::make_canonical_path(imp_path)),
|
75
|
+
ctx_path(File::make_canonical_path(ctx_path)),
|
76
|
+
base_path(File::dir_name(ctx_path))
|
77
|
+
{ }
|
78
|
+
};
|
79
|
+
|
80
|
+
// a resolved include (final import)
|
81
|
+
class Include : public Importer {
|
82
|
+
public:
|
83
|
+
// resolved absolute path
|
84
|
+
std::string abs_path;
|
85
|
+
public:
|
86
|
+
Include(const Importer& imp, std::string abs_path)
|
87
|
+
: Importer(imp), abs_path(abs_path)
|
88
|
+
{ }
|
89
|
+
};
|
90
|
+
|
91
|
+
// a loaded resource
|
92
|
+
class Resource {
|
93
|
+
public:
|
94
|
+
// the file contents
|
95
|
+
char* contents;
|
96
|
+
// conected sourcemap
|
97
|
+
char* srcmap;
|
98
|
+
public:
|
99
|
+
Resource(char* contents, char* srcmap)
|
100
|
+
: contents(contents), srcmap(srcmap)
|
101
|
+
{ }
|
102
|
+
};
|
103
|
+
|
104
|
+
// parsed stylesheet from loaded resource
|
105
|
+
class StyleSheet : public Resource {
|
106
|
+
public:
|
107
|
+
// parsed root block
|
108
|
+
Block* root;
|
109
|
+
public:
|
110
|
+
StyleSheet(const Resource& res, Block* root)
|
111
|
+
: Resource(res), root(root)
|
112
|
+
{ }
|
113
|
+
};
|
114
|
+
|
115
|
+
namespace File {
|
116
|
+
|
117
|
+
std::vector<Include> resolve_includes(const std::string& root, const std::string& file);
|
118
|
+
|
119
|
+
}
|
120
|
+
|
67
121
|
}
|
68
122
|
|
69
123
|
#endif
|
@@ -11,9 +11,9 @@
|
|
11
11
|
#include "util.hpp"
|
12
12
|
#include "expand.hpp"
|
13
13
|
#include "utf8_string.hpp"
|
14
|
+
#include "sass/base.h"
|
14
15
|
#include "utf8.h"
|
15
16
|
|
16
|
-
#include <atomic>
|
17
17
|
#include <cstdlib>
|
18
18
|
#include <cmath>
|
19
19
|
#include <cctype>
|
@@ -311,9 +311,9 @@ namespace Sass {
|
|
311
311
|
|
312
312
|
return SASS_MEMORY_NEW(ctx.mem, Color,
|
313
313
|
pstate,
|
314
|
-
|
315
|
-
|
316
|
-
|
314
|
+
Sass::round(w1*color1->r() + w2*color2->r()),
|
315
|
+
Sass::round(w1*color1->g() + w2*color2->g()),
|
316
|
+
Sass::round(w1*color1->b() + w2*color2->b()),
|
317
317
|
color1->a()*p + color2->a()*(1-p));
|
318
318
|
}
|
319
319
|
|
@@ -331,7 +331,7 @@ namespace Sass {
|
|
331
331
|
|
332
332
|
double max = std::max(r, std::max(g, b));
|
333
333
|
double min = std::min(r, std::min(g, b));
|
334
|
-
double
|
334
|
+
double delta = max - min;
|
335
335
|
|
336
336
|
double h = 0, s = 0, l = (max + min) / 2.0;
|
337
337
|
|
@@ -339,12 +339,12 @@ namespace Sass {
|
|
339
339
|
h = s = 0; // achromatic
|
340
340
|
}
|
341
341
|
else {
|
342
|
-
if (l < 0.5) s =
|
343
|
-
else s =
|
342
|
+
if (l < 0.5) s = delta / (max + min);
|
343
|
+
else s = delta / (2.0 - max - min);
|
344
344
|
|
345
|
-
if (r == max) h = (g - b) /
|
346
|
-
else if (g == max) h = (b - r) /
|
347
|
-
else if (b == max) h = (r - g) /
|
345
|
+
if (r == max) h = (g - b) / delta + (g < b ? 6 : 0);
|
346
|
+
else if (g == max) h = (b - r) / delta + 2;
|
347
|
+
else if (b == max) h = (r - g) / delta + 4;
|
348
348
|
}
|
349
349
|
|
350
350
|
HSL hsl_struct;
|
@@ -357,8 +357,8 @@ namespace Sass {
|
|
357
357
|
|
358
358
|
// hue to RGB helper function
|
359
359
|
double h_to_rgb(double m1, double m2, double h) {
|
360
|
-
|
361
|
-
|
360
|
+
while (h < 0) h += 1;
|
361
|
+
while (h > 1) h -= 1;
|
362
362
|
if (h*6.0 < 1) return m1 + (m2 - m1)*h*6;
|
363
363
|
if (h*2.0 < 1) return m2;
|
364
364
|
if (h*3.0 < 2) return m1 + (m2 - m1) * (2.0/3.0 - h)*6;
|
@@ -384,9 +384,9 @@ namespace Sass {
|
|
384
384
|
else m2 = (l+s)-(l*s);
|
385
385
|
double m1 = (l*2.0)-m2;
|
386
386
|
// round the results -- consider moving this into the Color constructor
|
387
|
-
double r = (h_to_rgb(m1, m2, h+1.0/3.0) * 255.0);
|
387
|
+
double r = (h_to_rgb(m1, m2, h + 1.0/3.0) * 255.0);
|
388
388
|
double g = (h_to_rgb(m1, m2, h) * 255.0);
|
389
|
-
double b = (h_to_rgb(m1, m2, h-1.0/3.0) * 255.0);
|
389
|
+
double b = (h_to_rgb(m1, m2, h - 1.0/3.0) * 255.0);
|
390
390
|
|
391
391
|
return SASS_MEMORY_NEW(ctx.mem, Color, pstate, r, g, b, a);
|
392
392
|
}
|
@@ -854,10 +854,10 @@ namespace Sass {
|
|
854
854
|
|
855
855
|
std::stringstream ss;
|
856
856
|
ss << '#' << std::setw(2) << std::setfill('0');
|
857
|
-
ss << std::hex << std::setw(2) << static_cast<unsigned long>(
|
858
|
-
ss << std::hex << std::setw(2) << static_cast<unsigned long>(
|
859
|
-
ss << std::hex << std::setw(2) << static_cast<unsigned long>(
|
860
|
-
ss << std::hex << std::setw(2) << static_cast<unsigned long>(
|
857
|
+
ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(a));
|
858
|
+
ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(r));
|
859
|
+
ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(g));
|
860
|
+
ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(b));
|
861
861
|
|
862
862
|
std::string result(ss.str());
|
863
863
|
for (size_t i = 0, L = result.length(); i < L; ++i) {
|
@@ -874,10 +874,7 @@ namespace Sass {
|
|
874
874
|
BUILT_IN(sass_unquote)
|
875
875
|
{
|
876
876
|
AST_Node* arg = env["$string"];
|
877
|
-
if (dynamic_cast<
|
878
|
-
return SASS_MEMORY_NEW(ctx.mem, Null, pstate);
|
879
|
-
}
|
880
|
-
else if (String_Quoted* string_quoted = dynamic_cast<String_Quoted*>(arg)) {
|
877
|
+
if (String_Quoted* string_quoted = dynamic_cast<String_Quoted*>(arg)) {
|
881
878
|
String_Constant* result = SASS_MEMORY_NEW(ctx.mem, String_Constant, pstate, string_quoted->value());
|
882
879
|
// remember if the string was quoted (color tokens)
|
883
880
|
result->sass_fix_1291(string_quoted->quote_mark() != 0);
|
@@ -887,9 +884,11 @@ namespace Sass {
|
|
887
884
|
return (Expression*) arg;
|
888
885
|
}
|
889
886
|
else {
|
890
|
-
To_String to_string(&ctx);
|
887
|
+
To_String to_string(&ctx, false, true);
|
891
888
|
std::string val(arg->perform(&to_string));
|
892
|
-
|
889
|
+
val = dynamic_cast<Null*>(arg) ? "null" : val;
|
890
|
+
|
891
|
+
deprecated_function("Passing " + val + ", a non-string value, to unquote()", pstate);
|
893
892
|
return (Expression*) arg;
|
894
893
|
}
|
895
894
|
}
|
@@ -1089,7 +1088,7 @@ namespace Sass {
|
|
1089
1088
|
Number* n = ARG("$number", Number);
|
1090
1089
|
Number* r = SASS_MEMORY_NEW(ctx.mem, Number, *n);
|
1091
1090
|
r->pstate(pstate);
|
1092
|
-
r->value(
|
1091
|
+
r->value(Sass::round(r->value()));
|
1093
1092
|
return r;
|
1094
1093
|
}
|
1095
1094
|
|
@@ -1156,7 +1155,10 @@ namespace Sass {
|
|
1156
1155
|
Signature random_sig = "random($limit:false)";
|
1157
1156
|
BUILT_IN(random)
|
1158
1157
|
{
|
1159
|
-
|
1158
|
+
AST_Node* arg = env["$limit"];
|
1159
|
+
Value* v = dynamic_cast<Value*>(arg);
|
1160
|
+
Number* l = dynamic_cast<Number*>(arg);
|
1161
|
+
Boolean* b = dynamic_cast<Boolean*>(arg);
|
1160
1162
|
if (l) {
|
1161
1163
|
double v = l->value();
|
1162
1164
|
if (v < 1) {
|
@@ -1174,11 +1176,16 @@ namespace Sass {
|
|
1174
1176
|
uint_fast32_t distributed = static_cast<uint_fast32_t>(distributor(rand));
|
1175
1177
|
return SASS_MEMORY_NEW(ctx.mem, Number, pstate, (double)distributed);
|
1176
1178
|
}
|
1177
|
-
else {
|
1179
|
+
else if (b) {
|
1178
1180
|
std::uniform_real_distribution<> distributor(0, 1);
|
1179
1181
|
double distributed = static_cast<double>(distributor(rand));
|
1180
1182
|
return SASS_MEMORY_NEW(ctx.mem, Number, pstate, distributed);
|
1181
|
-
|
1183
|
+
} else if (v) {
|
1184
|
+
throw Exception::InvalidArgumentType(pstate, "random", "$limit", "number", v);
|
1185
|
+
} else {
|
1186
|
+
throw Exception::InvalidArgumentType(pstate, "random", "$limit", "number");
|
1187
|
+
}
|
1188
|
+
return 0;
|
1182
1189
|
}
|
1183
1190
|
|
1184
1191
|
/////////////////
|
@@ -1668,13 +1675,13 @@ namespace Sass {
|
|
1668
1675
|
} else {
|
1669
1676
|
bool parentheses = v->concrete_type() == Expression::MAP ||
|
1670
1677
|
v->concrete_type() == Expression::LIST;
|
1671
|
-
|
1672
|
-
old_style = ctx.output_style;
|
1673
|
-
ctx.output_style =
|
1678
|
+
Sass_Output_Style old_style;
|
1679
|
+
old_style = ctx.c_options->output_style;
|
1680
|
+
ctx.c_options->output_style = SASS_STYLE_NESTED;
|
1674
1681
|
To_String to_string(&ctx, false);
|
1675
1682
|
std::string inspect = v->perform(&to_string);
|
1676
1683
|
if (inspect.empty() && parentheses) inspect = "()";
|
1677
|
-
ctx.output_style = old_style;
|
1684
|
+
ctx.c_options->output_style = old_style;
|
1678
1685
|
return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, inspect);
|
1679
1686
|
}
|
1680
1687
|
// return v;
|
data/ext/libsass/src/inspect.cpp
CHANGED
@@ -26,11 +26,11 @@ namespace Sass {
|
|
26
26
|
add_open_mapping(block);
|
27
27
|
append_scope_opener();
|
28
28
|
}
|
29
|
-
if (output_style() ==
|
29
|
+
if (output_style() == SASS_STYLE_NESTED) indentation += block->tabs();
|
30
30
|
for (size_t i = 0, L = block->length(); i < L; ++i) {
|
31
31
|
(*block)[i]->perform(this);
|
32
32
|
}
|
33
|
-
if (output_style() ==
|
33
|
+
if (output_style() == SASS_STYLE_NESTED) indentation -= block->tabs();
|
34
34
|
if (!block->is_root()) {
|
35
35
|
append_scope_closer();
|
36
36
|
add_close_mapping(block);
|
@@ -123,7 +123,7 @@ namespace Sass {
|
|
123
123
|
if (dec->value()->concrete_type() == Expression::NULL_VAL) return;
|
124
124
|
bool was_decl = in_declaration;
|
125
125
|
in_declaration = true;
|
126
|
-
if (output_style() ==
|
126
|
+
if (output_style() == SASS_STYLE_NESTED)
|
127
127
|
indentation += dec->tabs();
|
128
128
|
append_indentation();
|
129
129
|
dec->property()->perform(this);
|
@@ -141,7 +141,7 @@ namespace Sass {
|
|
141
141
|
append_string("!important");
|
142
142
|
}
|
143
143
|
append_delimiter();
|
144
|
-
if (output_style() ==
|
144
|
+
if (output_style() == SASS_STYLE_NESTED)
|
145
145
|
indentation -= dec->tabs();
|
146
146
|
in_declaration = was_decl;
|
147
147
|
}
|
@@ -198,7 +198,7 @@ namespace Sass {
|
|
198
198
|
append_indentation();
|
199
199
|
append_token("@import", import);
|
200
200
|
append_mandatory_space();
|
201
|
-
append_string(import->
|
201
|
+
append_string(import->imp_path());
|
202
202
|
append_delimiter();
|
203
203
|
}
|
204
204
|
|
@@ -363,7 +363,7 @@ namespace Sass {
|
|
363
363
|
void Inspect::operator()(List* list)
|
364
364
|
{
|
365
365
|
std::string sep(list->separator() == SASS_SPACE ? " " : ",");
|
366
|
-
if (output_style() !=
|
366
|
+
if ((output_style() != SASS_STYLE_COMPRESSED || in_debug) && sep == ",") sep += " ";
|
367
367
|
else if (in_media_block && sep != " ") sep += " "; // verified
|
368
368
|
if (list->empty()) return;
|
369
369
|
bool items_output = false;
|
@@ -459,8 +459,8 @@ namespace Sass {
|
|
459
459
|
void Inspect::operator()(Number* n)
|
460
460
|
{
|
461
461
|
// use values to_string facility
|
462
|
-
bool compressed = ctx->output_style ==
|
463
|
-
std::string res
|
462
|
+
bool compressed = ctx->output_style() == SASS_STYLE_COMPRESSED;
|
463
|
+
std::string res(n->to_string(compressed, (int)ctx->c_options->precision));
|
464
464
|
// output the final token
|
465
465
|
append_token(res, n);
|
466
466
|
}
|
@@ -468,8 +468,8 @@ namespace Sass {
|
|
468
468
|
void Inspect::operator()(Color* c)
|
469
469
|
{
|
470
470
|
// use values to_string facility
|
471
|
-
bool compressed = ctx->output_style ==
|
472
|
-
|
471
|
+
bool compressed = ctx->output_style() == SASS_STYLE_COMPRESSED;
|
472
|
+
std::string res(c->to_string(compressed, (int)ctx->c_options->precision));
|
473
473
|
// output the final token
|
474
474
|
append_token(res, c);
|
475
475
|
}
|
@@ -477,8 +477,8 @@ namespace Sass {
|
|
477
477
|
void Inspect::operator()(Boolean* b)
|
478
478
|
{
|
479
479
|
// use values to_string facility
|
480
|
-
bool compressed = ctx->output_style ==
|
481
|
-
|
480
|
+
bool compressed = ctx->output_style() == SASS_STYLE_COMPRESSED;
|
481
|
+
std::string res(b->to_string(compressed, (int)ctx->c_options->precision));
|
482
482
|
// output the final token
|
483
483
|
append_token(res, b);
|
484
484
|
}
|
@@ -497,8 +497,8 @@ namespace Sass {
|
|
497
497
|
void Inspect::operator()(String_Constant* s)
|
498
498
|
{
|
499
499
|
// get options from optional? context
|
500
|
-
int precision = ctx ? (int)ctx->precision : 5;
|
501
|
-
bool compressed = ctx ? ctx->output_style ==
|
500
|
+
int precision = ctx ? (int)ctx->c_options->precision : 5;
|
501
|
+
bool compressed = ctx ? ctx->output_style() == SASS_STYLE_COMPRESSED : false;
|
502
502
|
// use values to_string facility
|
503
503
|
std::string res(s->to_string(compressed, precision));
|
504
504
|
// output the final token
|
@@ -508,8 +508,8 @@ namespace Sass {
|
|
508
508
|
void Inspect::operator()(String_Quoted* s)
|
509
509
|
{
|
510
510
|
// get options from optional? context
|
511
|
-
int precision = ctx ? (int)ctx->precision : 5;
|
512
|
-
bool compressed = ctx ? ctx->output_style ==
|
511
|
+
int precision = ctx ? (int)ctx->c_options->precision : 5;
|
512
|
+
bool compressed = ctx ? ctx->output_style() == SASS_STYLE_COMPRESSED : false;
|
513
513
|
// use values to_string facility
|
514
514
|
std::string res(s->to_string(compressed, precision));
|
515
515
|
// output the final token
|
@@ -612,8 +612,8 @@ namespace Sass {
|
|
612
612
|
void Inspect::operator()(Null* n)
|
613
613
|
{
|
614
614
|
// use values to_string facility
|
615
|
-
bool compressed =
|
616
|
-
std::string res
|
615
|
+
bool compressed = output_style() == SASS_STYLE_COMPRESSED;
|
616
|
+
std::string res(n->to_string(compressed, (int)ctx->c_options->precision));
|
617
617
|
// output the final token
|
618
618
|
append_token(res, n);
|
619
619
|
}
|
@@ -752,7 +752,7 @@ namespace Sass {
|
|
752
752
|
(*s)[i]->perform(this);
|
753
753
|
}
|
754
754
|
if (s->has_line_break()) {
|
755
|
-
if (output_style() !=
|
755
|
+
if (output_style() != SASS_STYLE_COMPACT) {
|
756
756
|
append_optional_linefeed();
|
757
757
|
}
|
758
758
|
}
|
@@ -774,7 +774,7 @@ namespace Sass {
|
|
774
774
|
if (head && head->length() != 0) head->perform(this);
|
775
775
|
bool is_empty = !head || head->length() == 0 || head->is_empty_reference();
|
776
776
|
bool is_tail = head && !head->is_empty_reference() && tail;
|
777
|
-
if (output_style() ==
|
777
|
+
if (output_style() == SASS_STYLE_COMPRESSED && comb != Complex_Selector::ANCESTOR_OF) scheduled_space = 0;
|
778
778
|
|
779
779
|
switch (comb) {
|
780
780
|
case Complex_Selector::ANCESTOR_OF:
|
@@ -810,7 +810,7 @@ namespace Sass {
|
|
810
810
|
}
|
811
811
|
if (tail) tail->perform(this);
|
812
812
|
if (!tail && c->has_line_break()) {
|
813
|
-
if (output_style() ==
|
813
|
+
if (output_style() == SASS_STYLE_COMPACT) {
|
814
814
|
append_mandatory_space();
|
815
815
|
}
|
816
816
|
}
|