sassc 1.8.3 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/ext/libsass/.editorconfig +1 -1
  4. data/ext/libsass/.gitignore +1 -0
  5. data/ext/libsass/LICENSE +1 -1
  6. data/ext/libsass/Makefile +20 -14
  7. data/ext/libsass/Makefile.conf +0 -1
  8. data/ext/libsass/Readme.md +3 -1
  9. data/ext/libsass/appveyor.yml +19 -11
  10. data/ext/libsass/docs/api-importer-example.md +2 -1235
  11. data/ext/libsass/docs/build-with-autotools.md +10 -0
  12. data/ext/libsass/docs/build-with-makefiles.md +18 -0
  13. data/ext/libsass/include/sass/base.h +4 -1
  14. data/ext/libsass/include/sass/values.h +2 -1
  15. data/ext/libsass/src/ast.cpp +279 -346
  16. data/ext/libsass/src/ast.hpp +234 -60
  17. data/ext/libsass/src/base64vlq.cpp +1 -0
  18. data/ext/libsass/src/bind.cpp +35 -45
  19. data/ext/libsass/src/bind.hpp +1 -0
  20. data/ext/libsass/src/color_maps.cpp +1 -0
  21. data/ext/libsass/src/constants.cpp +4 -1
  22. data/ext/libsass/src/constants.hpp +2 -1
  23. data/ext/libsass/src/context.cpp +41 -31
  24. data/ext/libsass/src/context.hpp +10 -10
  25. data/ext/libsass/src/cssize.cpp +7 -4
  26. data/ext/libsass/src/cssize.hpp +1 -3
  27. data/ext/libsass/src/debugger.hpp +73 -14
  28. data/ext/libsass/src/emitter.cpp +37 -25
  29. data/ext/libsass/src/emitter.hpp +10 -9
  30. data/ext/libsass/src/environment.cpp +16 -5
  31. data/ext/libsass/src/environment.hpp +5 -3
  32. data/ext/libsass/src/error_handling.cpp +91 -14
  33. data/ext/libsass/src/error_handling.hpp +105 -4
  34. data/ext/libsass/src/eval.cpp +519 -330
  35. data/ext/libsass/src/eval.hpp +12 -13
  36. data/ext/libsass/src/expand.cpp +92 -56
  37. data/ext/libsass/src/expand.hpp +5 -3
  38. data/ext/libsass/src/extend.cpp +60 -51
  39. data/ext/libsass/src/extend.hpp +1 -3
  40. data/ext/libsass/src/file.cpp +37 -27
  41. data/ext/libsass/src/functions.cpp +78 -62
  42. data/ext/libsass/src/functions.hpp +1 -0
  43. data/ext/libsass/src/inspect.cpp +293 -64
  44. data/ext/libsass/src/inspect.hpp +2 -0
  45. data/ext/libsass/src/lexer.cpp +1 -0
  46. data/ext/libsass/src/listize.cpp +14 -15
  47. data/ext/libsass/src/listize.hpp +3 -5
  48. data/ext/libsass/src/memory_manager.cpp +1 -0
  49. data/ext/libsass/src/node.cpp +2 -3
  50. data/ext/libsass/src/operation.hpp +70 -71
  51. data/ext/libsass/src/output.cpp +28 -32
  52. data/ext/libsass/src/output.hpp +1 -2
  53. data/ext/libsass/src/parser.cpp +402 -183
  54. data/ext/libsass/src/parser.hpp +19 -9
  55. data/ext/libsass/src/plugins.cpp +1 -0
  56. data/ext/libsass/src/position.cpp +1 -0
  57. data/ext/libsass/src/prelexer.cpp +134 -56
  58. data/ext/libsass/src/prelexer.hpp +51 -3
  59. data/ext/libsass/src/remove_placeholders.cpp +35 -9
  60. data/ext/libsass/src/remove_placeholders.hpp +4 -3
  61. data/ext/libsass/src/sass.cpp +1 -0
  62. data/ext/libsass/src/sass.hpp +129 -0
  63. data/ext/libsass/src/sass_context.cpp +31 -14
  64. data/ext/libsass/src/sass_context.hpp +2 -31
  65. data/ext/libsass/src/sass_functions.cpp +1 -0
  66. data/ext/libsass/src/sass_interface.cpp +5 -6
  67. data/ext/libsass/src/sass_util.cpp +1 -2
  68. data/ext/libsass/src/sass_util.hpp +5 -5
  69. data/ext/libsass/src/sass_values.cpp +13 -10
  70. data/ext/libsass/src/source_map.cpp +4 -3
  71. data/ext/libsass/src/source_map.hpp +2 -2
  72. data/ext/libsass/src/subset_map.hpp +0 -1
  73. data/ext/libsass/src/to_c.cpp +1 -0
  74. data/ext/libsass/src/to_c.hpp +1 -3
  75. data/ext/libsass/src/to_value.cpp +3 -5
  76. data/ext/libsass/src/to_value.hpp +1 -1
  77. data/ext/libsass/src/units.cpp +96 -59
  78. data/ext/libsass/src/units.hpp +10 -8
  79. data/ext/libsass/src/utf8_string.cpp +5 -0
  80. data/ext/libsass/src/util.cpp +23 -156
  81. data/ext/libsass/src/util.hpp +10 -14
  82. data/ext/libsass/src/values.cpp +1 -0
  83. data/ext/libsass/test/test_node.cpp +2 -6
  84. data/ext/libsass/test/test_selector_difference.cpp +1 -3
  85. data/ext/libsass/test/test_specificity.cpp +0 -2
  86. data/ext/libsass/test/test_superselector.cpp +0 -2
  87. data/ext/libsass/test/test_unification.cpp +1 -3
  88. data/ext/libsass/win/libsass.targets +18 -5
  89. data/ext/libsass/win/libsass.vcxproj +9 -7
  90. data/ext/libsass/win/libsass.vcxproj.filters +148 -106
  91. data/lib/sassc/version.rb +1 -1
  92. data/test/engine_test.rb +12 -0
  93. data/test/native_test.rb +1 -1
  94. metadata +3 -4
  95. data/ext/libsass/src/to_string.cpp +0 -48
  96. data/ext/libsass/src/to_string.hpp +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4711ad9a2cb9091ae22ff8fb0c373f767212dbec
4
- data.tar.gz: 5d51cbb258d5855a729028c1db0ce35871e991cb
3
+ metadata.gz: 8fe1d16ee2088d1a7579e272a1a7e06ec45fcfc4
4
+ data.tar.gz: fdf4b18309732cf9657becf31f4cf42170cce51c
5
5
  SHA512:
6
- metadata.gz: ea92abeccd8eda5bd3c7c7dfa7e64bd8bab8182891ff6bb9fcb11f995ab2b6e45c6bb5a0a2260c5eb55131e4ef409bf9754aae6ef50524e2c3f0ea3900bd18a0
7
- data.tar.gz: 4d3defd176979708077f1f80fb549643e471092097f201f86e0cf702ec23e90407173bafde4abee9d697ee9ba5f42cf33cf17e1b2f9dc0a9a3138d4395540684
6
+ metadata.gz: 9182f4bbf92967e5dae1c870427d372d1bb672f7fab914a4b412d032ab2391456a2989dc5313e71f9e50d476e905d16ee72de22038136ead8674c58a074a38cb
7
+ data.tar.gz: 80fe5528ca2af133a4075ee84b9b3aafd0f1c8eb11aa73ac827eaf96cdedbd349ad933f5f0a990fffeb43ce96b866de0b2bed50f3b5c809dfe5f22f9dde6096f
data/README.md CHANGED
@@ -6,7 +6,7 @@ This gem combines the speed of `libsass`, the [Sass C implementation](https://gi
6
6
 
7
7
  ### libsass Version
8
8
 
9
- [3.3.2](https://github.com/sass/libsass/releases/tag/3.3.2)
9
+ [3.3.3](https://github.com/sass/libsass/releases/tag/3.3.3)
10
10
 
11
11
  ## Usage
12
12
 
@@ -25,6 +25,8 @@ and [awesome contributors](https://github.com/bolandrm/sassc-ruby/graphs/contrib
25
25
 
26
26
  ## Changelog
27
27
 
28
+ - **1.8.4**
29
+ - Update to Libsass 3.3.3
28
30
  - **1.8.3**
29
31
  - [Passing empty string into engine does not raise error](https://github.com/sass/sassc-ruby/pull/31)
30
32
  - **1.8.2**
@@ -10,6 +10,6 @@ insert_final_newline = true
10
10
  indent_style = spaces
11
11
  indent_size = 2
12
12
 
13
- [{Makefile, Makefile.am}]
13
+ [{Makefile, GNUmakefile.am}]
14
14
  indent_style = tab
15
15
  indent_size = 4
@@ -50,6 +50,7 @@ libsass/*
50
50
  *.a
51
51
  *.suo
52
52
  *.sdf
53
+ *.opendb
53
54
  *.opensdf
54
55
  a.out
55
56
  libsass.js
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (C) 2012 by Hampton Catlin
2
+ Copyright (C) 2012-2016 by Hampton Catlin
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy of
5
5
  this software and associated documentation files (the "Software"), to deal in
@@ -1,3 +1,4 @@
1
+ OS ?= $(shell uname -s)
1
2
  CC ?= gcc
2
3
  CXX ?= g++
3
4
  RM ?= rm -f
@@ -5,6 +6,11 @@ CP ?= cp -a
5
6
  MKDIR ?= mkdir
6
7
  RMDIR ?= rmdir
7
8
  WINDRES ?= windres
9
+ # Solaris/Illumos flavors
10
+ # ginstall from coreutils
11
+ ifeq ($(OS),SunOS)
12
+ INSTALL ?= ginstall
13
+ endif
8
14
  INSTALL ?= install
9
15
  CFLAGS ?= -Wall
10
16
  CXXFLAGS ?= -Wall
@@ -20,14 +26,14 @@ CAT ?= $(if $(filter $(OS),Windows_NT),type,cat)
20
26
  ifneq (,$(findstring /cygdrive/,$(PATH)))
21
27
  UNAME := Cygwin
22
28
  else
23
- ifneq (,$(findstring WINDOWS,$(PATH)))
29
+ ifneq (,$(findstring Windows_NT,$(OS)))
24
30
  UNAME := Windows
25
31
  else
26
32
  ifneq (,$(findstring mingw32,$(MAKE)))
27
- UNAME := MinGW
33
+ UNAME := Windows
28
34
  else
29
35
  ifneq (,$(findstring MINGW32,$(shell uname -s)))
30
- UNAME = MinGW
36
+ UNAME = Windows
31
37
  else
32
38
  UNAME := $(shell uname -s)
33
39
  endif
@@ -57,7 +63,7 @@ ifneq ($(LIBSASS_VERSION),)
57
63
  endif
58
64
 
59
65
  # enable mandatory flag
60
- ifeq (MinGW,$(UNAME))
66
+ ifeq (Windows,$(UNAME))
61
67
  ifneq ($(BUILD),shared)
62
68
  STATIC_ALL ?= 1
63
69
  endif
@@ -117,7 +123,7 @@ ifeq ($(UNAME),Darwin)
117
123
  LDFLAGS += -stdlib=libc++
118
124
  endif
119
125
 
120
- ifneq (MinGW,$(UNAME))
126
+ ifneq (Windows,$(UNAME))
121
127
  ifneq (FreeBSD,$(UNAME))
122
128
  LDFLAGS += -ldl
123
129
  LDLIBS += -ldl
@@ -128,14 +134,17 @@ ifneq ($(BUILD),shared)
128
134
  BUILD = static
129
135
  endif
130
136
 
131
- ifeq (,$(PREFIX))
132
- ifeq (,$(TRAVIS_BUILD_DIR))
133
- PREFIX = /usr/local
137
+ ifeq (,$(TRAVIS_BUILD_DIR))
138
+ ifeq ($(OS),SunOS)
139
+ PREFIX ?= /opt/local
134
140
  else
135
- PREFIX = $(TRAVIS_BUILD_DIR)
141
+ PREFIX ?= /usr/local
136
142
  endif
143
+ else
144
+ PREFIX ?= $(TRAVIS_BUILD_DIR)
137
145
  endif
138
146
 
147
+
139
148
  SASS_SASSC_PATH ?= sassc
140
149
  SASS_SPEC_PATH ?= sass-spec
141
150
  SASS_SPEC_SPEC_DIR ?= spec
@@ -145,7 +154,7 @@ RUBY_BIN = ruby
145
154
  LIB_STATIC = $(SASS_LIBSASS_PATH)/lib/libsass.a
146
155
  LIB_SHARED = $(SASS_LIBSASS_PATH)/lib/libsass.so
147
156
 
148
- ifeq (MinGW,$(UNAME))
157
+ ifeq (Windows,$(UNAME))
149
158
  ifeq (shared,$(BUILD))
150
159
  CFLAGS += -D ADD_EXPORTS
151
160
  CXXFLAGS += -D ADD_EXPORTS
@@ -159,9 +168,6 @@ else
159
168
  endif
160
169
  endif
161
170
 
162
- ifeq (MinGW,$(UNAME))
163
- SASSC_BIN = $(SASS_SASSC_PATH)/bin/sassc.exe
164
- endif
165
171
  ifeq (Windows,$(UNAME))
166
172
  SASSC_BIN = $(SASS_SASSC_PATH)/bin/sassc.exe
167
173
  endif
@@ -171,7 +177,7 @@ include Makefile.conf
171
177
  RESOURCES =
172
178
  STATICLIB = lib/libsass.a
173
179
  SHAREDLIB = lib/libsass.so
174
- ifeq (MinGW,$(UNAME))
180
+ ifeq (Windows,$(UNAME))
175
181
  RESOURCES += res/resource.rc
176
182
  SHAREDLIB = lib/libsass.dll
177
183
  ifeq (shared,$(BUILD))
@@ -37,7 +37,6 @@ SOURCES = \
37
37
  sass2scss.cpp \
38
38
  source_map.cpp \
39
39
  to_c.cpp \
40
- to_string.cpp \
41
40
  to_value.cpp \
42
41
  units.cpp \
43
42
  utf8_string.cpp \
@@ -1,7 +1,7 @@
1
1
  LibSass
2
2
  =======
3
3
 
4
- by Aaron Leung ([@akhleung]) and Hampton Catlin ([@hcatlin])
4
+ by Aaron Leung ([@akhleung]), Hampton Catlin ([@hcatlin]), Marcel Greter ([@mgreter]) and Michael Mifsud ([@xzyfer])
5
5
 
6
6
  [![Linux CI](https://travis-ci.org/sass/libsass.png?branch=master)](https://travis-ci.org/sass/libsass)
7
7
  [![Windows CI](https://ci.appveyor.com/api/projects/status/github/sass/libsass?svg=true)](https://ci.appveyor.com/project/sass/libsass/branch/master)
@@ -89,6 +89,8 @@ Our MIT license is designed to be as simple, and liberal as possible.
89
89
  [@akhleung]: https://github.com/akhleung
90
90
  [@chriseppstein]: https://github.com/chriseppstein
91
91
  [@nex3]: https://github.com/nex3
92
+ [@mgreter]: https://github.com/mgreter
93
+ [@xzyfer]: https://github.com/xzyfer
92
94
 
93
95
  sass2scss was originally written by [Marcel Greter](@mgreter)
94
96
  and he happily agreed to have it merged into the project.
@@ -1,4 +1,4 @@
1
- os: Visual Studio 2015
1
+ os: Visual Studio 2015
2
2
 
3
3
  environment:
4
4
  CTEST_OUTPUT_ON_FAILURE: 1
@@ -27,9 +27,7 @@ install:
27
27
  if ($env:Compiler -eq "mingw" -AND -Not (Test-Path "C:\mingw64")) {
28
28
  # Install MinGW.
29
29
  $file = "x86_64-4.9.2-release-win32-seh-rt_v4-rev3.7z"
30
- $url = "https://bintray.com/artifact/download/drewwells/generic/"
31
- $url += $file
32
- Invoke-WebRequest -UserAgent wget -Uri $url -OutFile $file
30
+ wget https://bintray.com/artifact/download/drewwells/generic/$file -OutFile $file
33
31
  &7z x -oC:\ $file > $null
34
32
  }
35
33
  - set PATH=C:\mingw64\bin;%PATH%
@@ -53,18 +51,28 @@ build_script:
53
51
 
54
52
  test_script:
55
53
  - ps: |
56
- $PRNR = [System.Environment]::ExpandEnvironmentVariables("%APPVEYOR_PULL_REQUEST_NUMBER%")
57
- if ($PRNR -ne "") {
54
+ $PRNR = $env:APPVEYOR_PULL_REQUEST_NUMBER
55
+ if ($PRNR) {
58
56
  echo "Fetching info for PR $PRNR"
59
- $request = (New-Object System.Net.WebClient)
60
- $request.headers['User-Agent'] = "Mozilla/5.0"
61
- $request.DownloadFile( "https://api.github.com/repos/sass/libsass/pulls/$PRNR", 'pr.json')
62
- $json = [IO.File]::ReadAllText('pr.json')
57
+ wget https://api.github.com/repos/sass/libsass/pulls/$PRNR -OutFile pr.json
58
+ $json = cat pr.json -Raw
63
59
  $SPEC_PR = [regex]::match($json,'sass\/sass-spec(#|\/pull\/)([0-9]+)').Groups[2].Value
64
- if ($SPEC_PR -ne "") {
60
+ if ($SPEC_PR) {
65
61
  echo "Checkout sass spec PR $SPEC_PR"
66
62
  git -C sass-spec fetch -q -u origin pull/$SPEC_PR/head:ci-spec-pr-$SPEC_PR
67
63
  git -C sass-spec checkout -q --force ci-spec-pr-$SPEC_PR
68
64
  }
69
65
  }
70
66
  ruby sass-spec/sass-spec.rb -c $env:TargetPath -s --ignore-todo sass-spec/spec
67
+
68
+ Write-Host "Explicitly testing the case when cwd has Cyrillic characters: " -nonewline
69
+ # See comments in gh-1774 for details.
70
+ $env:TargetPath = Join-Path $pwd.Path $env:TargetPath
71
+ cd sass-spec/spec/libsass/Sáss-UŢF8/
72
+ &$env:TargetPath ./input.scss 2>&1>$null
73
+ if(-not($?)) {
74
+ echo "Failed!"
75
+ exit 1
76
+ } else {
77
+ echo "Success!"
78
+ }
@@ -75,7 +75,7 @@ Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_
75
75
  // swallows »@import "http://…"« pass-through
76
76
  // (arguably a bug)
77
77
  Sass_Import_List list = sass_make_import_list(1);
78
- list[0] = sass_make_import_entry(url, 0, 0);
78
+ list[0] = sass_make_import_entry(path, 0, 0);
79
79
  return list;
80
80
  }
81
81
 
@@ -83,7 +83,7 @@ Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_
83
83
  // return an error to halt execution
84
84
  Sass_Import_List list = sass_make_import_list(1);
85
85
  const char* message = "some error message";
86
- list[0] = sass_make_import_entry(url, 0, 0);
86
+ list[0] = sass_make_import_entry(path, 0, 0);
87
87
  sass_import_set_error(list[0], strdup(message), 0, 0);
88
88
  return list;
89
89
  }
@@ -110,1236 +110,3 @@ Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_
110
110
  return list;
111
111
  }
112
112
  ```
113
- ## Example importer.c
114
-
115
- ```C
116
- #include <stdio.h>
117
- #include <string.h>
118
- #include "sass/context.h"
119
-
120
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
121
- {
122
- // get the cookie from importer descriptor
123
- void* cookie = sass_importer_get_cookie(cb);
124
- Sass_Import_List list = sass_make_import_list(2);
125
- const char* local = "local { color: green; }";
126
- const char* remote = "remote { color: red; }";
127
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
128
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
129
- return list;
130
- }
131
-
132
- int main( int argc, const char* argv[] )
133
- {
134
-
135
- // get the input file from first argument or use default
136
- const char* input = argc > 1 ? argv[1] : "styles.scss";
137
-
138
- // create the file context and get all related structs
139
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
140
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
141
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
142
-
143
- // allocate custom importer
144
- Sass_Importer_Entry c_imp =
145
- sass_make_importer(sass_importer, 0, 0);
146
- // create list for all custom importers
147
- Sass_Importer_List imp_list = sass_make_importer_list(1);
148
- // put the only importer on to the list
149
- sass_importer_set_list_entry(imp_list, 0, c_imp);
150
- // register list on to the context options
151
- sass_option_set_c_importers(ctx_opt, imp_list);
152
- // context is set up, call the compile step now
153
- int status = sass_compile_file_context(file_ctx);
154
-
155
- // print the result or the error to the stdout
156
- if (status == 0) puts(sass_context_get_output_string(ctx));
157
- else puts(sass_context_get_error_message(ctx));
158
-
159
- // release allocated memory
160
- sass_delete_file_context(file_ctx);
161
-
162
- // exit status
163
- return status;
164
-
165
- }
166
- ```
167
-
168
- Compile importer.c
169
-
170
- ```bash
171
- gcc -c importer.c -o importer.o
172
- gcc -o importer importer.o -lsass
173
- echo "@import 'foobar';" > importer.scss
174
- ./importer importer.scss
175
- ```
176
-
177
- ## Importer Behavior Examples
178
-
179
- ```C
180
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
181
- // let LibSass handle the import request
182
- return NULL;
183
- }
184
-
185
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
186
- // let LibSass handle the request
187
- // swallows »@import "http://…"« pass-through
188
- // (arguably a bug)
189
- Sass_Import_List list = sass_make_import_list(1);
190
- list[0] = sass_make_import_entry(url, 0, 0);
191
- return list;
192
- }
193
-
194
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
195
- // return an error to halt execution
196
- Sass_Import_List list = sass_make_import_list(1);
197
- const char* message = "some error message";
198
- list[0] = sass_make_import_entry(url, 0, 0);
199
- sass_import_set_error(list[0], strdup(message), 0, 0);
200
- return list;
201
- }
202
-
203
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
204
- // let LibSass load the file identifed by the importer
205
- Sass_Import_List list = sass_make_import_list(1);
206
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
207
- return list;
208
- }
209
-
210
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
211
- // completely hide the import
212
- // (arguably a bug)
213
- Sass_Import_List list = sass_make_import_list(0);
214
- return list;
215
- }
216
-
217
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
218
- // completely hide the import
219
- // (arguably a bug)
220
- Sass_Import_List list = sass_make_import_list(1);
221
- list[0] = sass_make_import_entry(0, 0, 0);
222
- return list;
223
- }
224
- ```
225
- ## Example importer.c
226
-
227
- ```C
228
- #include <stdio.h>
229
- #include <string.h>
230
- #include "sass/context.h"
231
-
232
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
233
- {
234
- // get the cookie from importer descriptor
235
- void* cookie = sass_importer_get_cookie(cb);
236
- Sass_Import_List list = sass_make_import_list(2);
237
- const char* local = "local { color: green; }";
238
- const char* remote = "remote { color: red; }";
239
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
240
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
241
- return list;
242
- }
243
-
244
- int main( int argc, const char* argv[] )
245
- {
246
-
247
- // get the input file from first argument or use default
248
- const char* input = argc > 1 ? argv[1] : "styles.scss";
249
-
250
- // create the file context and get all related structs
251
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
252
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
253
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
254
-
255
- // allocate custom importer
256
- Sass_Importer_Entry c_imp =
257
- sass_make_importer(sass_importer, 0, 0);
258
- // create list for all custom importers
259
- Sass_Importer_List imp_list = sass_make_importer_list(1);
260
- // put the only importer on to the list
261
- sass_importer_set_list_entry(imp_list, 0, c_imp);
262
- // register list on to the context options
263
- sass_option_set_c_importers(ctx_opt, imp_list);
264
- // context is set up, call the compile step now
265
- int status = sass_compile_file_context(file_ctx);
266
-
267
- // print the result or the error to the stdout
268
- if (status == 0) puts(sass_context_get_output_string(ctx));
269
- else puts(sass_context_get_error_message(ctx));
270
-
271
- // release allocated memory
272
- sass_delete_file_context(file_ctx);
273
-
274
- // exit status
275
- return status;
276
-
277
- }
278
- ```
279
-
280
- Compile importer.c
281
-
282
- ```bash
283
- gcc -c importer.c -o importer.o
284
- gcc -o importer importer.o -lsass
285
- echo "@import 'foobar';" > importer.scss
286
- ./importer importer.scss
287
- ```
288
-
289
- ## Importer Behavior Examples
290
-
291
- ```C
292
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
293
- // let LibSass handle the import request
294
- return NULL;
295
- }
296
-
297
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
298
- // let LibSass handle the request
299
- // swallows »@import "http://…"« pass-through
300
- // (arguably a bug)
301
- Sass_Import_List list = sass_make_import_list(1);
302
- list[0] = sass_make_import_entry(url, 0, 0);
303
- return list;
304
- }
305
-
306
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
307
- // return an error to halt execution
308
- Sass_Import_List list = sass_make_import_list(1);
309
- const char* message = "some error message";
310
- list[0] = sass_make_import_entry(url, 0, 0);
311
- sass_import_set_error(list[0], strdup(message), 0, 0);
312
- return list;
313
- }
314
-
315
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
316
- // let LibSass load the file identifed by the importer
317
- Sass_Import_List list = sass_make_import_list(1);
318
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
319
- return list;
320
- }
321
-
322
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
323
- // completely hide the import
324
- // (arguably a bug)
325
- Sass_Import_List list = sass_make_import_list(0);
326
- return list;
327
- }
328
-
329
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
330
- // completely hide the import
331
- // (arguably a bug)
332
- Sass_Import_List list = sass_make_import_list(1);
333
- list[0] = sass_make_import_entry(0, 0, 0);
334
- return list;
335
- }
336
- ```
337
- ## Example importer.c
338
-
339
- ```C
340
- #include <stdio.h>
341
- #include <string.h>
342
- #include "sass/context.h"
343
-
344
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
345
- {
346
- // get the cookie from importer descriptor
347
- void* cookie = sass_importer_get_cookie(cb);
348
- Sass_Import_List list = sass_make_import_list(2);
349
- const char* local = "local { color: green; }";
350
- const char* remote = "remote { color: red; }";
351
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
352
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
353
- return list;
354
- }
355
-
356
- int main( int argc, const char* argv[] )
357
- {
358
-
359
- // get the input file from first argument or use default
360
- const char* input = argc > 1 ? argv[1] : "styles.scss";
361
-
362
- // create the file context and get all related structs
363
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
364
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
365
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
366
-
367
- // allocate custom importer
368
- Sass_Importer_Entry c_imp =
369
- sass_make_importer(sass_importer, 0, 0);
370
- // create list for all custom importers
371
- Sass_Importer_List imp_list = sass_make_importer_list(1);
372
- // put the only importer on to the list
373
- sass_importer_set_list_entry(imp_list, 0, c_imp);
374
- // register list on to the context options
375
- sass_option_set_c_importers(ctx_opt, imp_list);
376
- // context is set up, call the compile step now
377
- int status = sass_compile_file_context(file_ctx);
378
-
379
- // print the result or the error to the stdout
380
- if (status == 0) puts(sass_context_get_output_string(ctx));
381
- else puts(sass_context_get_error_message(ctx));
382
-
383
- // release allocated memory
384
- sass_delete_file_context(file_ctx);
385
-
386
- // exit status
387
- return status;
388
-
389
- }
390
- ```
391
-
392
- Compile importer.c
393
-
394
- ```bash
395
- gcc -c importer.c -o importer.o
396
- gcc -o importer importer.o -lsass
397
- echo "@import 'foobar';" > importer.scss
398
- ./importer importer.scss
399
- ```
400
-
401
- ## Importer Behavior Examples
402
-
403
- ```C
404
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
405
- // let LibSass handle the import request
406
- return NULL;
407
- }
408
-
409
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
410
- // let LibSass handle the request
411
- // swallows »@import "http://…"« pass-through
412
- // (arguably a bug)
413
- Sass_Import_List list = sass_make_import_list(1);
414
- list[0] = sass_make_import_entry(url, 0, 0);
415
- return list;
416
- }
417
-
418
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
419
- // return an error to halt execution
420
- Sass_Import_List list = sass_make_import_list(1);
421
- const char* message = "some error message";
422
- list[0] = sass_make_import_entry(url, 0, 0);
423
- sass_import_set_error(list[0], strdup(message), 0, 0);
424
- return list;
425
- }
426
-
427
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
428
- // let LibSass load the file identifed by the importer
429
- Sass_Import_List list = sass_make_import_list(1);
430
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
431
- return list;
432
- }
433
-
434
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
435
- // completely hide the import
436
- // (arguably a bug)
437
- Sass_Import_List list = sass_make_import_list(0);
438
- return list;
439
- }
440
-
441
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
442
- // completely hide the import
443
- // (arguably a bug)
444
- Sass_Import_List list = sass_make_import_list(1);
445
- list[0] = sass_make_import_entry(0, 0, 0);
446
- return list;
447
- }
448
- ```
449
- ## Example importer.c
450
-
451
- ```C
452
- #include <stdio.h>
453
- #include <string.h>
454
- #include "sass/context.h"
455
-
456
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
457
- {
458
- // get the cookie from importer descriptor
459
- void* cookie = sass_importer_get_cookie(cb);
460
- Sass_Import_List list = sass_make_import_list(2);
461
- const char* local = "local { color: green; }";
462
- const char* remote = "remote { color: red; }";
463
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
464
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
465
- return list;
466
- }
467
-
468
- int main( int argc, const char* argv[] )
469
- {
470
-
471
- // get the input file from first argument or use default
472
- const char* input = argc > 1 ? argv[1] : "styles.scss";
473
-
474
- // create the file context and get all related structs
475
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
476
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
477
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
478
-
479
- // allocate custom importer
480
- Sass_Importer_Entry c_imp =
481
- sass_make_importer(sass_importer, 0, 0);
482
- // create list for all custom importers
483
- Sass_Importer_List imp_list = sass_make_importer_list(1);
484
- // put the only importer on to the list
485
- sass_importer_set_list_entry(imp_list, 0, c_imp);
486
- // register list on to the context options
487
- sass_option_set_c_importers(ctx_opt, imp_list);
488
- // context is set up, call the compile step now
489
- int status = sass_compile_file_context(file_ctx);
490
-
491
- // print the result or the error to the stdout
492
- if (status == 0) puts(sass_context_get_output_string(ctx));
493
- else puts(sass_context_get_error_message(ctx));
494
-
495
- // release allocated memory
496
- sass_delete_file_context(file_ctx);
497
-
498
- // exit status
499
- return status;
500
-
501
- }
502
- ```
503
-
504
- Compile importer.c
505
-
506
- ```bash
507
- gcc -c importer.c -o importer.o
508
- gcc -o importer importer.o -lsass
509
- echo "@import 'foobar';" > importer.scss
510
- ./importer importer.scss
511
- ```
512
-
513
- ## Importer Behavior Examples
514
-
515
- ```C
516
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
517
- // let LibSass handle the import request
518
- return NULL;
519
- }
520
-
521
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
522
- // let LibSass handle the request
523
- // swallows »@import "http://…"« pass-through
524
- // (arguably a bug)
525
- Sass_Import_List list = sass_make_import_list(1);
526
- list[0] = sass_make_import_entry(url, 0, 0);
527
- return list;
528
- }
529
-
530
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
531
- // return an error to halt execution
532
- Sass_Import_List list = sass_make_import_list(1);
533
- const char* message = "some error message";
534
- list[0] = sass_make_import_entry(url, 0, 0);
535
- sass_import_set_error(list[0], strdup(message), 0, 0);
536
- return list;
537
- }
538
-
539
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
540
- // let LibSass load the file identifed by the importer
541
- Sass_Import_List list = sass_make_import_list(1);
542
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
543
- return list;
544
- }
545
-
546
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
547
- // completely hide the import
548
- // (arguably a bug)
549
- Sass_Import_List list = sass_make_import_list(0);
550
- return list;
551
- }
552
-
553
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
554
- // completely hide the import
555
- // (arguably a bug)
556
- Sass_Import_List list = sass_make_import_list(1);
557
- list[0] = sass_make_import_entry(0, 0, 0);
558
- return list;
559
- }
560
- ```
561
- ## Example importer.c
562
-
563
- ```C
564
- #include <stdio.h>
565
- #include <string.h>
566
- #include "sass/context.h"
567
-
568
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
569
- {
570
- // get the cookie from importer descriptor
571
- void* cookie = sass_importer_get_cookie(cb);
572
- Sass_Import_List list = sass_make_import_list(2);
573
- const char* local = "local { color: green; }";
574
- const char* remote = "remote { color: red; }";
575
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
576
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
577
- return list;
578
- }
579
-
580
- int main( int argc, const char* argv[] )
581
- {
582
-
583
- // get the input file from first argument or use default
584
- const char* input = argc > 1 ? argv[1] : "styles.scss";
585
-
586
- // create the file context and get all related structs
587
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
588
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
589
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
590
-
591
- // allocate custom importer
592
- Sass_Importer_Entry c_imp =
593
- sass_make_importer(sass_importer, 0, 0);
594
- // create list for all custom importers
595
- Sass_Importer_List imp_list = sass_make_importer_list(1);
596
- // put the only importer on to the list
597
- sass_importer_set_list_entry(imp_list, 0, c_imp);
598
- // register list on to the context options
599
- sass_option_set_c_importers(ctx_opt, imp_list);
600
- // context is set up, call the compile step now
601
- int status = sass_compile_file_context(file_ctx);
602
-
603
- // print the result or the error to the stdout
604
- if (status == 0) puts(sass_context_get_output_string(ctx));
605
- else puts(sass_context_get_error_message(ctx));
606
-
607
- // release allocated memory
608
- sass_delete_file_context(file_ctx);
609
-
610
- // exit status
611
- return status;
612
-
613
- }
614
- ```
615
-
616
- Compile importer.c
617
-
618
- ```bash
619
- gcc -c importer.c -o importer.o
620
- gcc -o importer importer.o -lsass
621
- echo "@import 'foobar';" > importer.scss
622
- ./importer importer.scss
623
- ```
624
-
625
- ## Importer Behavior Examples
626
-
627
- ```C
628
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
629
- // let LibSass handle the import request
630
- return NULL;
631
- }
632
-
633
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
634
- // let LibSass handle the request
635
- // swallows »@import "http://…"« pass-through
636
- // (arguably a bug)
637
- Sass_Import_List list = sass_make_import_list(1);
638
- list[0] = sass_make_import_entry(url, 0, 0);
639
- return list;
640
- }
641
-
642
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
643
- // return an error to halt execution
644
- Sass_Import_List list = sass_make_import_list(1);
645
- const char* message = "some error message";
646
- list[0] = sass_make_import_entry(url, 0, 0);
647
- sass_import_set_error(list[0], strdup(message), 0, 0);
648
- return list;
649
- }
650
-
651
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
652
- // let LibSass load the file identifed by the importer
653
- Sass_Import_List list = sass_make_import_list(1);
654
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
655
- return list;
656
- }
657
-
658
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
659
- // completely hide the import
660
- // (arguably a bug)
661
- Sass_Import_List list = sass_make_import_list(0);
662
- return list;
663
- }
664
-
665
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
666
- // completely hide the import
667
- // (arguably a bug)
668
- Sass_Import_List list = sass_make_import_list(1);
669
- list[0] = sass_make_import_entry(0, 0, 0);
670
- return list;
671
- }
672
- ```
673
- ## Example importer.c
674
-
675
- ```C
676
- #include <stdio.h>
677
- #include <string.h>
678
- #include "sass/context.h"
679
-
680
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
681
- {
682
- // get the cookie from importer descriptor
683
- void* cookie = sass_importer_get_cookie(cb);
684
- Sass_Import_List list = sass_make_import_list(2);
685
- const char* local = "local { color: green; }";
686
- const char* remote = "remote { color: red; }";
687
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
688
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
689
- return list;
690
- }
691
-
692
- int main( int argc, const char* argv[] )
693
- {
694
-
695
- // get the input file from first argument or use default
696
- const char* input = argc > 1 ? argv[1] : "styles.scss";
697
-
698
- // create the file context and get all related structs
699
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
700
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
701
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
702
-
703
- // allocate custom importer
704
- Sass_Importer_Entry c_imp =
705
- sass_make_importer(sass_importer, 0, 0);
706
- // create list for all custom importers
707
- Sass_Importer_List imp_list = sass_make_importer_list(1);
708
- // put the only importer on to the list
709
- sass_importer_set_list_entry(imp_list, 0, c_imp);
710
- // register list on to the context options
711
- sass_option_set_c_importers(ctx_opt, imp_list);
712
- // context is set up, call the compile step now
713
- int status = sass_compile_file_context(file_ctx);
714
-
715
- // print the result or the error to the stdout
716
- if (status == 0) puts(sass_context_get_output_string(ctx));
717
- else puts(sass_context_get_error_message(ctx));
718
-
719
- // release allocated memory
720
- sass_delete_file_context(file_ctx);
721
-
722
- // exit status
723
- return status;
724
-
725
- }
726
- ```
727
-
728
- Compile importer.c
729
-
730
- ```bash
731
- gcc -c importer.c -o importer.o
732
- gcc -o importer importer.o -lsass
733
- echo "@import 'foobar';" > importer.scss
734
- ./importer importer.scss
735
- ```
736
-
737
- ## Importer Behavior Examples
738
-
739
- ```C
740
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
741
- // let LibSass handle the import request
742
- return NULL;
743
- }
744
-
745
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
746
- // let LibSass handle the request
747
- // swallows »@import "http://…"« pass-through
748
- // (arguably a bug)
749
- Sass_Import_List list = sass_make_import_list(1);
750
- list[0] = sass_make_import_entry(url, 0, 0);
751
- return list;
752
- }
753
-
754
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
755
- // return an error to halt execution
756
- Sass_Import_List list = sass_make_import_list(1);
757
- const char* message = "some error message";
758
- list[0] = sass_make_import_entry(url, 0, 0);
759
- sass_import_set_error(list[0], strdup(message), 0, 0);
760
- return list;
761
- }
762
-
763
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
764
- // let LibSass load the file identifed by the importer
765
- Sass_Import_List list = sass_make_import_list(1);
766
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
767
- return list;
768
- }
769
-
770
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
771
- // completely hide the import
772
- // (arguably a bug)
773
- Sass_Import_List list = sass_make_import_list(0);
774
- return list;
775
- }
776
-
777
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
778
- // completely hide the import
779
- // (arguably a bug)
780
- Sass_Import_List list = sass_make_import_list(1);
781
- list[0] = sass_make_import_entry(0, 0, 0);
782
- return list;
783
- }
784
- ```
785
- ## Example importer.c
786
-
787
- ```C
788
- #include <stdio.h>
789
- #include <string.h>
790
- #include "sass/context.h"
791
-
792
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
793
- {
794
- // get the cookie from importer descriptor
795
- void* cookie = sass_importer_get_cookie(cb);
796
- Sass_Import_List list = sass_make_import_list(2);
797
- const char* local = "local { color: green; }";
798
- const char* remote = "remote { color: red; }";
799
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
800
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
801
- return list;
802
- }
803
-
804
- int main( int argc, const char* argv[] )
805
- {
806
-
807
- // get the input file from first argument or use default
808
- const char* input = argc > 1 ? argv[1] : "styles.scss";
809
-
810
- // create the file context and get all related structs
811
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
812
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
813
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
814
-
815
- // allocate custom importer
816
- Sass_Importer_Entry c_imp =
817
- sass_make_importer(sass_importer, 0, 0);
818
- // create list for all custom importers
819
- Sass_Importer_List imp_list = sass_make_importer_list(1);
820
- // put the only importer on to the list
821
- sass_importer_set_list_entry(imp_list, 0, c_imp);
822
- // register list on to the context options
823
- sass_option_set_c_importers(ctx_opt, imp_list);
824
- // context is set up, call the compile step now
825
- int status = sass_compile_file_context(file_ctx);
826
-
827
- // print the result or the error to the stdout
828
- if (status == 0) puts(sass_context_get_output_string(ctx));
829
- else puts(sass_context_get_error_message(ctx));
830
-
831
- // release allocated memory
832
- sass_delete_file_context(file_ctx);
833
-
834
- // exit status
835
- return status;
836
-
837
- }
838
- ```
839
-
840
- Compile importer.c
841
-
842
- ```bash
843
- gcc -c importer.c -o importer.o
844
- gcc -o importer importer.o -lsass
845
- echo "@import 'foobar';" > importer.scss
846
- ./importer importer.scss
847
- ```
848
-
849
- ## Importer Behavior Examples
850
-
851
- ```C
852
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
853
- // let LibSass handle the import request
854
- return NULL;
855
- }
856
-
857
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
858
- // let LibSass handle the request
859
- // swallows »@import "http://…"« pass-through
860
- // (arguably a bug)
861
- Sass_Import_List list = sass_make_import_list(1);
862
- list[0] = sass_make_import_entry(url, 0, 0);
863
- return list;
864
- }
865
-
866
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
867
- // return an error to halt execution
868
- Sass_Import_List list = sass_make_import_list(1);
869
- const char* message = "some error message";
870
- list[0] = sass_make_import_entry(url, 0, 0);
871
- sass_import_set_error(list[0], strdup(message), 0, 0);
872
- return list;
873
- }
874
-
875
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
876
- // let LibSass load the file identifed by the importer
877
- Sass_Import_List list = sass_make_import_list(1);
878
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
879
- return list;
880
- }
881
-
882
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
883
- // completely hide the import
884
- // (arguably a bug)
885
- Sass_Import_List list = sass_make_import_list(0);
886
- return list;
887
- }
888
-
889
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
890
- // completely hide the import
891
- // (arguably a bug)
892
- Sass_Import_List list = sass_make_import_list(1);
893
- list[0] = sass_make_import_entry(0, 0, 0);
894
- return list;
895
- }
896
- ```
897
- ## Example importer.c
898
-
899
- ```C
900
- #include <stdio.h>
901
- #include <string.h>
902
- #include "sass/context.h"
903
-
904
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
905
- {
906
- // get the cookie from importer descriptor
907
- void* cookie = sass_importer_get_cookie(cb);
908
- Sass_Import_List list = sass_make_import_list(2);
909
- const char* local = "local { color: green; }";
910
- const char* remote = "remote { color: red; }";
911
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
912
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
913
- return list;
914
- }
915
-
916
- int main( int argc, const char* argv[] )
917
- {
918
-
919
- // get the input file from first argument or use default
920
- const char* input = argc > 1 ? argv[1] : "styles.scss";
921
-
922
- // create the file context and get all related structs
923
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
924
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
925
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
926
-
927
- // allocate custom importer
928
- Sass_Importer_Entry c_imp =
929
- sass_make_importer(sass_importer, 0, 0);
930
- // create list for all custom importers
931
- Sass_Importer_List imp_list = sass_make_importer_list(1);
932
- // put the only importer on to the list
933
- sass_importer_set_list_entry(imp_list, 0, c_imp);
934
- // register list on to the context options
935
- sass_option_set_c_importers(ctx_opt, imp_list);
936
- // context is set up, call the compile step now
937
- int status = sass_compile_file_context(file_ctx);
938
-
939
- // print the result or the error to the stdout
940
- if (status == 0) puts(sass_context_get_output_string(ctx));
941
- else puts(sass_context_get_error_message(ctx));
942
-
943
- // release allocated memory
944
- sass_delete_file_context(file_ctx);
945
-
946
- // exit status
947
- return status;
948
-
949
- }
950
- ```
951
-
952
- Compile importer.c
953
-
954
- ```bash
955
- gcc -c importer.c -o importer.o
956
- gcc -o importer importer.o -lsass
957
- echo "@import 'foobar';" > importer.scss
958
- ./importer importer.scss
959
- ```
960
-
961
- ## Importer Behavior Examples
962
-
963
- ```C
964
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
965
- // let LibSass handle the import request
966
- return NULL;
967
- }
968
-
969
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
970
- // let LibSass handle the request
971
- // swallows »@import "http://…"« pass-through
972
- // (arguably a bug)
973
- Sass_Import_List list = sass_make_import_list(1);
974
- list[0] = sass_make_import_entry(url, 0, 0);
975
- return list;
976
- }
977
-
978
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
979
- // return an error to halt execution
980
- Sass_Import_List list = sass_make_import_list(1);
981
- const char* message = "some error message";
982
- list[0] = sass_make_import_entry(url, 0, 0);
983
- sass_import_set_error(list[0], strdup(message), 0, 0);
984
- return list;
985
- }
986
-
987
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
988
- // let LibSass load the file identifed by the importer
989
- Sass_Import_List list = sass_make_import_list(1);
990
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
991
- return list;
992
- }
993
-
994
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
995
- // completely hide the import
996
- // (arguably a bug)
997
- Sass_Import_List list = sass_make_import_list(0);
998
- return list;
999
- }
1000
-
1001
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1002
- // completely hide the import
1003
- // (arguably a bug)
1004
- Sass_Import_List list = sass_make_import_list(1);
1005
- list[0] = sass_make_import_entry(0, 0, 0);
1006
- return list;
1007
- }
1008
- ```
1009
- ## Example importer.c
1010
-
1011
- ```C
1012
- #include <stdio.h>
1013
- #include <string.h>
1014
- #include "sass/context.h"
1015
-
1016
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
1017
- {
1018
- // get the cookie from importer descriptor
1019
- void* cookie = sass_importer_get_cookie(cb);
1020
- Sass_Import_List list = sass_make_import_list(2);
1021
- const char* local = "local { color: green; }";
1022
- const char* remote = "remote { color: red; }";
1023
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
1024
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
1025
- return list;
1026
- }
1027
-
1028
- int main( int argc, const char* argv[] )
1029
- {
1030
-
1031
- // get the input file from first argument or use default
1032
- const char* input = argc > 1 ? argv[1] : "styles.scss";
1033
-
1034
- // create the file context and get all related structs
1035
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
1036
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
1037
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
1038
-
1039
- // allocate custom importer
1040
- Sass_Importer_Entry c_imp =
1041
- sass_make_importer(sass_importer, 0, 0);
1042
- // create list for all custom importers
1043
- Sass_Importer_List imp_list = sass_make_importer_list(1);
1044
- // put the only importer on to the list
1045
- sass_importer_set_list_entry(imp_list, 0, c_imp);
1046
- // register list on to the context options
1047
- sass_option_set_c_importers(ctx_opt, imp_list);
1048
- // context is set up, call the compile step now
1049
- int status = sass_compile_file_context(file_ctx);
1050
-
1051
- // print the result or the error to the stdout
1052
- if (status == 0) puts(sass_context_get_output_string(ctx));
1053
- else puts(sass_context_get_error_message(ctx));
1054
-
1055
- // release allocated memory
1056
- sass_delete_file_context(file_ctx);
1057
-
1058
- // exit status
1059
- return status;
1060
-
1061
- }
1062
- ```
1063
-
1064
- Compile importer.c
1065
-
1066
- ```bash
1067
- gcc -c importer.c -o importer.o
1068
- gcc -o importer importer.o -lsass
1069
- echo "@import 'foobar';" > importer.scss
1070
- ./importer importer.scss
1071
- ```
1072
-
1073
- ## Importer Behavior Examples
1074
-
1075
- ```C
1076
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1077
- // let LibSass handle the import request
1078
- return NULL;
1079
- }
1080
-
1081
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1082
- // let LibSass handle the request
1083
- // swallows »@import "http://…"« pass-through
1084
- // (arguably a bug)
1085
- Sass_Import_List list = sass_make_import_list(1);
1086
- list[0] = sass_make_import_entry(url, 0, 0);
1087
- return list;
1088
- }
1089
-
1090
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1091
- // return an error to halt execution
1092
- Sass_Import_List list = sass_make_import_list(1);
1093
- const char* message = "some error message";
1094
- list[0] = sass_make_import_entry(url, 0, 0);
1095
- sass_import_set_error(list[0], strdup(message), 0, 0);
1096
- return list;
1097
- }
1098
-
1099
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1100
- // let LibSass load the file identifed by the importer
1101
- Sass_Import_List list = sass_make_import_list(1);
1102
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
1103
- return list;
1104
- }
1105
-
1106
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1107
- // completely hide the import
1108
- // (arguably a bug)
1109
- Sass_Import_List list = sass_make_import_list(0);
1110
- return list;
1111
- }
1112
-
1113
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1114
- // completely hide the import
1115
- // (arguably a bug)
1116
- Sass_Import_List list = sass_make_import_list(1);
1117
- list[0] = sass_make_import_entry(0, 0, 0);
1118
- return list;
1119
- }
1120
- ```
1121
- ## Example importer.c
1122
-
1123
- ```C
1124
- #include <stdio.h>
1125
- #include <string.h>
1126
- #include "sass/context.h"
1127
-
1128
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
1129
- {
1130
- // get the cookie from importer descriptor
1131
- void* cookie = sass_importer_get_cookie(cb);
1132
- Sass_Import_List list = sass_make_import_list(2);
1133
- const char* local = "local { color: green; }";
1134
- const char* remote = "remote { color: red; }";
1135
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
1136
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
1137
- return list;
1138
- }
1139
-
1140
- int main( int argc, const char* argv[] )
1141
- {
1142
-
1143
- // get the input file from first argument or use default
1144
- const char* input = argc > 1 ? argv[1] : "styles.scss";
1145
-
1146
- // create the file context and get all related structs
1147
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
1148
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
1149
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
1150
-
1151
- // allocate custom importer
1152
- Sass_Importer_Entry c_imp =
1153
- sass_make_importer(sass_importer, 0, 0);
1154
- // create list for all custom importers
1155
- Sass_Importer_List imp_list = sass_make_importer_list(1);
1156
- // put the only importer on to the list
1157
- sass_importer_set_list_entry(imp_list, 0, c_imp);
1158
- // register list on to the context options
1159
- sass_option_set_c_importers(ctx_opt, imp_list);
1160
- // context is set up, call the compile step now
1161
- int status = sass_compile_file_context(file_ctx);
1162
-
1163
- // print the result or the error to the stdout
1164
- if (status == 0) puts(sass_context_get_output_string(ctx));
1165
- else puts(sass_context_get_error_message(ctx));
1166
-
1167
- // release allocated memory
1168
- sass_delete_file_context(file_ctx);
1169
-
1170
- // exit status
1171
- return status;
1172
-
1173
- }
1174
- ```
1175
-
1176
- Compile importer.c
1177
-
1178
- ```bash
1179
- gcc -c importer.c -o importer.o
1180
- gcc -o importer importer.o -lsass
1181
- echo "@import 'foobar';" > importer.scss
1182
- ./importer importer.scss
1183
- ```
1184
-
1185
- ## Importer Behavior Examples
1186
-
1187
- ```C
1188
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1189
- // let LibSass handle the import request
1190
- return NULL;
1191
- }
1192
-
1193
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1194
- // let LibSass handle the request
1195
- // swallows »@import "http://…"« pass-through
1196
- // (arguably a bug)
1197
- Sass_Import_List list = sass_make_import_list(1);
1198
- list[0] = sass_make_import_entry(url, 0, 0);
1199
- return list;
1200
- }
1201
-
1202
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1203
- // return an error to halt execution
1204
- Sass_Import_List list = sass_make_import_list(1);
1205
- const char* message = "some error message";
1206
- list[0] = sass_make_import_entry(url, 0, 0);
1207
- sass_import_set_error(list[0], strdup(message), 0, 0);
1208
- return list;
1209
- }
1210
-
1211
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1212
- // let LibSass load the file identifed by the importer
1213
- Sass_Import_List list = sass_make_import_list(1);
1214
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
1215
- return list;
1216
- }
1217
-
1218
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1219
- // completely hide the import
1220
- // (arguably a bug)
1221
- Sass_Import_List list = sass_make_import_list(0);
1222
- return list;
1223
- }
1224
-
1225
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1226
- // completely hide the import
1227
- // (arguably a bug)
1228
- Sass_Import_List list = sass_make_import_list(1);
1229
- list[0] = sass_make_import_entry(0, 0, 0);
1230
- return list;
1231
- }
1232
- ```
1233
- ## Example importer.c
1234
-
1235
- ```C
1236
- #include <stdio.h>
1237
- #include <string.h>
1238
- #include "sass/context.h"
1239
-
1240
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
1241
- {
1242
- // get the cookie from importer descriptor
1243
- void* cookie = sass_importer_get_cookie(cb);
1244
- Sass_Import_List list = sass_make_import_list(2);
1245
- const char* local = "local { color: green; }";
1246
- const char* remote = "remote { color: red; }";
1247
- list[0] = sass_make_import_entry("/tmp/styles.scss", strdup(local), 0);
1248
- list[1] = sass_make_import_entry("http://www.example.com", strdup(remote), 0);
1249
- return list;
1250
- }
1251
-
1252
- int main( int argc, const char* argv[] )
1253
- {
1254
-
1255
- // get the input file from first argument or use default
1256
- const char* input = argc > 1 ? argv[1] : "styles.scss";
1257
-
1258
- // create the file context and get all related structs
1259
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
1260
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
1261
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
1262
-
1263
- // allocate custom importer
1264
- Sass_Importer_Entry c_imp =
1265
- sass_make_importer(sass_importer, 0, 0);
1266
- // create list for all custom importers
1267
- Sass_Importer_List imp_list = sass_make_importer_list(1);
1268
- // put the only importer on to the list
1269
- sass_importer_set_list_entry(imp_list, 0, c_imp);
1270
- // register list on to the context options
1271
- sass_option_set_c_importers(ctx_opt, imp_list);
1272
- // context is set up, call the compile step now
1273
- int status = sass_compile_file_context(file_ctx);
1274
-
1275
- // print the result or the error to the stdout
1276
- if (status == 0) puts(sass_context_get_output_string(ctx));
1277
- else puts(sass_context_get_error_message(ctx));
1278
-
1279
- // release allocated memory
1280
- sass_delete_file_context(file_ctx);
1281
-
1282
- // exit status
1283
- return status;
1284
-
1285
- }
1286
- ```
1287
-
1288
- Compile importer.c
1289
-
1290
- ```bash
1291
- gcc -c importer.c -o importer.o
1292
- gcc -o importer importer.o -lsass
1293
- echo "@import 'foobar';" > importer.scss
1294
- ./importer importer.scss
1295
- ```
1296
-
1297
- ## Importer Behavior Examples
1298
-
1299
- ```C
1300
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1301
- // let LibSass handle the import request
1302
- return NULL;
1303
- }
1304
-
1305
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1306
- // let LibSass handle the request
1307
- // swallows »@import "http://…"« pass-through
1308
- // (arguably a bug)
1309
- Sass_Import_List list = sass_make_import_list(1);
1310
- list[0] = sass_make_import_entry(url, 0, 0);
1311
- return list;
1312
- }
1313
-
1314
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1315
- // return an error to halt execution
1316
- Sass_Import_List list = sass_make_import_list(1);
1317
- const char* message = "some error message";
1318
- list[0] = sass_make_import_entry(url, 0, 0);
1319
- sass_import_set_error(list[0], strdup(message), 0, 0);
1320
- return list;
1321
- }
1322
-
1323
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1324
- // let LibSass load the file identifed by the importer
1325
- Sass_Import_List list = sass_make_import_list(1);
1326
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
1327
- return list;
1328
- }
1329
-
1330
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1331
- // completely hide the import
1332
- // (arguably a bug)
1333
- Sass_Import_List list = sass_make_import_list(0);
1334
- return list;
1335
- }
1336
-
1337
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
1338
- // completely hide the import
1339
- // (arguably a bug)
1340
- Sass_Import_List list = sass_make_import_list(1);
1341
- list[0] = sass_make_import_entry(0, 0, 0);
1342
- return list;
1343
- }
1344
- ```
1345
-