jekyll-sass-converter 2.2.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/converters/sass.rb +2 -4
- data/lib/jekyll/converters/scss.rb +100 -144
- data/lib/jekyll/source_map_page.rb +1 -1
- data/lib/jekyll-sass-converter/version.rb +1 -1
- metadata +12 -74
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 103c0bfb64880d66c26803c4ab4152989630d2de956c5804c34cb499403c9f56
|
4
|
+
data.tar.gz: 95df7cdae357c75703ce0382443caf68f26ecf3163b2f4ed47c9d6bddf37d79e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17eccbb64b470845fb69d43a92885be52d6d9744323cab930a102b8b98ae9c81bf630bbe23fc9bef330324fc132df9f6214f97935c21f192b47ca358ae87d5f4
|
7
|
+
data.tar.gz: dc9faee94ce564f6b7cc5cd0af8c53ebdc783f60662682a85ba0a5b70e6e70b6649bc5f6524ff9bfa044b5c1254a0c71daa1b17e640f1cc538dadf7c6b5749c8
|
@@ -1,19 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "sassc"
|
4
|
-
require "jekyll/utils"
|
5
3
|
require "jekyll/converters/scss"
|
6
4
|
|
7
5
|
module Jekyll
|
8
6
|
module Converters
|
9
7
|
class Sass < Scss
|
10
|
-
EXTENSION_PATTERN = %r!^\.sass$!i
|
8
|
+
EXTENSION_PATTERN = %r!^\.sass$!i
|
11
9
|
|
12
10
|
safe true
|
13
11
|
priority :low
|
14
12
|
|
15
13
|
def syntax
|
16
|
-
:
|
14
|
+
:indented
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
@@ -1,14 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require "
|
5
|
-
|
3
|
+
# stdlib
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
# 3rd party
|
7
|
+
require "addressable/uri"
|
8
|
+
require "sass-embedded"
|
9
|
+
|
10
|
+
# internal
|
11
|
+
require_relative "../source_map_page"
|
6
12
|
|
7
13
|
module Jekyll
|
8
14
|
module Converters
|
9
15
|
class Scss < Converter
|
10
|
-
|
11
|
-
EXTENSION_PATTERN = %r!^\.scss$!i.freeze
|
16
|
+
EXTENSION_PATTERN = %r!^\.scss$!i
|
12
17
|
|
13
18
|
SyntaxError = Class.new(ArgumentError)
|
14
19
|
|
@@ -35,8 +40,7 @@ module Jekyll
|
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
38
|
-
|
39
|
-
ALLOWED_STYLES = %w(nested expanded compact compressed).freeze
|
43
|
+
ALLOWED_STYLES = %w(expanded compressed).freeze
|
40
44
|
|
41
45
|
# Associate this Converter with the "page" object that manages input and output files for
|
42
46
|
# this converter.
|
@@ -85,20 +89,12 @@ module Jekyll
|
|
85
89
|
@jekyll_sass_configuration ||= begin
|
86
90
|
options = @config["sass"] || {}
|
87
91
|
unless options["style"].nil?
|
88
|
-
options["style"] = options["style"].to_s.
|
92
|
+
options["style"] = options["style"].to_s.delete_prefix(":").to_sym
|
89
93
|
end
|
90
94
|
options
|
91
95
|
end
|
92
96
|
end
|
93
97
|
|
94
|
-
def sass_build_configuration_options(overrides)
|
95
|
-
return overrides if safe?
|
96
|
-
|
97
|
-
Jekyll::Utils.symbolize_hash_keys(
|
98
|
-
Jekyll::Utils.deep_merge_hashes(jekyll_sass_configuration, overrides)
|
99
|
-
)
|
100
|
-
end
|
101
|
-
|
102
98
|
def syntax
|
103
99
|
:scss
|
104
100
|
end
|
@@ -109,17 +105,9 @@ module Jekyll
|
|
109
105
|
jekyll_sass_configuration["sass_dir"]
|
110
106
|
end
|
111
107
|
|
112
|
-
def sass_implementation
|
113
|
-
implementation = jekyll_sass_configuration["implementation"]
|
114
|
-
ALLOWED_IMPLEMENTATIONS.include?(implementation) ? implementation : "sassc"
|
115
|
-
end
|
116
|
-
|
117
108
|
def sass_style
|
118
|
-
|
119
|
-
|
120
|
-
default = sass_implementation == "sassc" ? :compact : :expanded
|
121
|
-
style = jekyll_sass_configuration.fetch("style", default)
|
122
|
-
ALLOWED_STYLES.include?(style.to_s) ? style.to_sym : default
|
109
|
+
style = jekyll_sass_configuration["style"]
|
110
|
+
ALLOWED_STYLES.include?(style.to_s) ? style.to_sym : :expanded
|
123
111
|
end
|
124
112
|
|
125
113
|
def user_sass_load_paths
|
@@ -127,9 +115,8 @@ module Jekyll
|
|
127
115
|
end
|
128
116
|
|
129
117
|
def sass_dir_relative_to_site_source
|
130
|
-
@sass_dir_relative_to_site_source ||=
|
131
|
-
Jekyll.sanitized_path(site_source, sass_dir).
|
132
|
-
end
|
118
|
+
@sass_dir_relative_to_site_source ||=
|
119
|
+
Jekyll.sanitized_path(site_source, sass_dir).delete_prefix("#{site.source}/")
|
133
120
|
end
|
134
121
|
|
135
122
|
# rubocop:disable Metrics/AbcSize
|
@@ -155,74 +142,48 @@ module Jekyll
|
|
155
142
|
end
|
156
143
|
# rubocop:enable Metrics/AbcSize
|
157
144
|
|
158
|
-
def allow_caching?
|
159
|
-
!safe?
|
160
|
-
end
|
161
|
-
|
162
|
-
def add_charset?
|
163
|
-
!!jekyll_sass_configuration["add_charset"]
|
164
|
-
end
|
165
|
-
|
166
145
|
def sass_configs
|
167
|
-
sass_build_configuration_options(
|
168
|
-
:style => sass_style,
|
169
|
-
:syntax => syntax,
|
170
|
-
:filename => filename,
|
171
|
-
:output_path => output_path,
|
172
|
-
:source_map_file => source_map_file,
|
173
|
-
:load_paths => sass_load_paths,
|
174
|
-
:omit_source_map_url => !sourcemap_required?,
|
175
|
-
:source_map_contents => true,
|
176
|
-
:line_comments_option => line_comments_option
|
177
|
-
)
|
178
|
-
end
|
179
|
-
|
180
|
-
def convert(content)
|
181
|
-
case sass_implementation
|
182
|
-
when "sass-embedded"
|
183
|
-
Jekyll::External.require_with_graceful_fail("sass-embedded")
|
184
|
-
sass_embedded_convert(content)
|
185
|
-
when "sassc"
|
186
|
-
sass_convert(content)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
private
|
191
|
-
|
192
|
-
def sass_convert(content)
|
193
|
-
config = sass_configs
|
194
|
-
engine = SassC::Engine.new(content.dup, config)
|
195
|
-
output = engine.render
|
196
|
-
sass_generate_source_map(engine) if sourcemap_required?
|
197
|
-
replacement = add_charset? ? '@charset "UTF-8";' : ""
|
198
|
-
output.sub(BYTE_ORDER_MARK, replacement)
|
199
|
-
rescue SassC::SyntaxError => e
|
200
|
-
raise SyntaxError, e.to_s
|
201
|
-
end
|
202
|
-
|
203
|
-
def sass_embedded_config
|
204
146
|
{
|
205
147
|
:load_paths => sass_load_paths,
|
148
|
+
:charset => !associate_page_failed?,
|
206
149
|
:source_map => sourcemap_required?,
|
207
150
|
:source_map_include_sources => true,
|
208
151
|
:style => sass_style,
|
209
|
-
:syntax => syntax
|
152
|
+
:syntax => syntax,
|
210
153
|
:url => sass_file_url,
|
154
|
+
:quiet_deps => quiet_deps_option,
|
155
|
+
:verbose => verbose_option,
|
156
|
+
:fatal_deprecations => fatal_deprecations,
|
157
|
+
:future_deprecations => future_deprecations,
|
158
|
+
:silence_deprecations => silence_deprecations,
|
211
159
|
}
|
212
160
|
end
|
213
161
|
|
214
|
-
def
|
215
|
-
output = ::Sass.compile_string(content, **
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
162
|
+
def convert(content)
|
163
|
+
output = ::Sass.compile_string(content, **sass_configs)
|
164
|
+
result = output.css
|
165
|
+
|
166
|
+
if sourcemap_required?
|
167
|
+
source_map = process_source_map(output.source_map)
|
168
|
+
generate_source_map_page(source_map)
|
169
|
+
|
170
|
+
if (sm_url = source_mapping_url)
|
171
|
+
result += "#{sass_style == :compressed ? "" : "\n\n"}/*# sourceMappingURL=#{sm_url} */"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
result
|
221
176
|
rescue ::Sass::CompileError => e
|
222
177
|
Jekyll.logger.error e.full_message
|
223
|
-
|
178
|
+
if livereload?
|
179
|
+
e.to_css # Render error message in browser window
|
180
|
+
else
|
181
|
+
raise SyntaxError, e.message
|
182
|
+
end
|
224
183
|
end
|
225
184
|
|
185
|
+
private
|
186
|
+
|
226
187
|
# The Page instance for which this object acts as a converter.
|
227
188
|
attr_reader :sass_page
|
228
189
|
|
@@ -230,30 +191,16 @@ module Jekyll
|
|
230
191
|
!sass_page
|
231
192
|
end
|
232
193
|
|
233
|
-
#
|
234
|
-
|
235
|
-
|
236
|
-
# Returns the name of the input file or "stdin" if #associate_page failed
|
237
|
-
def filename
|
238
|
-
return "stdin" if associate_page_failed?
|
239
|
-
|
240
|
-
File.join(site_source_relative_from_pwd, sass_page.name)
|
194
|
+
# Returns `true` if jekyll is serving with livereload.
|
195
|
+
def livereload?
|
196
|
+
!!(@config["serving"] && @config["livereload"])
|
241
197
|
end
|
242
198
|
|
243
199
|
# The URL of the input scss (or sass) file. This information will be used for error reporting.
|
244
200
|
def sass_file_url
|
245
201
|
return if associate_page_failed?
|
246
202
|
|
247
|
-
file_url_from_path(
|
248
|
-
end
|
249
|
-
|
250
|
-
# The value of the `line_comments` option.
|
251
|
-
# When set to `true` causes the line number and filename of the source be emitted into the
|
252
|
-
# compiled CSS-file. Useful for debugging when the source-map is not available.
|
253
|
-
#
|
254
|
-
# Returns the value of the `line_comments`-option chosen by the user or 'false' by default.
|
255
|
-
def line_comments_option
|
256
|
-
jekyll_sass_configuration.fetch("line_comments", false)
|
203
|
+
file_url_from_path(Jekyll.sanitized_path(site_source, sass_page.relative_path))
|
257
204
|
end
|
258
205
|
|
259
206
|
# The value of the `sourcemap` option chosen by the user.
|
@@ -275,56 +222,49 @@ module Jekyll
|
|
275
222
|
!(sourcemap_option == :development && Jekyll.env != "development")
|
276
223
|
end
|
277
224
|
|
278
|
-
# The name of the generated css file. This information will be written into the source map
|
279
|
-
# file as a backward reference to the input.
|
280
|
-
#
|
281
|
-
# Returns the name of the css file or "stdin.css" if #associate_page failed
|
282
|
-
def output_path
|
283
|
-
return "stdin.css" if associate_page_failed?
|
284
|
-
|
285
|
-
File.join(site_source_relative_from_pwd, sass_page.basename + ".css")
|
286
|
-
end
|
287
|
-
|
288
|
-
# The name of the generated source map file. This information will be written into the
|
289
|
-
# css file to reference to the source map.
|
290
|
-
#
|
291
|
-
# Returns the name of the css file or "" if #associate_page failed
|
292
|
-
def source_map_file
|
293
|
-
return "" if associate_page_failed?
|
294
|
-
|
295
|
-
File.join(site_source_relative_from_pwd, sass_page.basename + ".css.map")
|
296
|
-
end
|
297
|
-
|
298
225
|
def source_map_page
|
299
226
|
return if associate_page_failed?
|
300
227
|
|
301
228
|
@source_map_page ||= SourceMapPage.new(sass_page)
|
302
229
|
end
|
303
230
|
|
304
|
-
#
|
231
|
+
# Returns the directory that source map sources are relative to.
|
232
|
+
def sass_source_root
|
233
|
+
if associate_page_failed?
|
234
|
+
site_source
|
235
|
+
else
|
236
|
+
Jekyll.sanitized_path(site_source, File.dirname(sass_page.relative_path))
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
# Converts file urls in source map to relative paths.
|
305
241
|
#
|
306
|
-
#
|
307
|
-
def
|
242
|
+
# Returns processed source map string.
|
243
|
+
def process_source_map(source_map)
|
244
|
+
map_data = JSON.parse(source_map)
|
245
|
+
unless associate_page_failed?
|
246
|
+
map_data["file"] = Addressable::URI.encode("#{sass_page.basename}.css")
|
247
|
+
end
|
248
|
+
source_root_url = Addressable::URI.parse(file_url_from_path("#{sass_source_root}/"))
|
249
|
+
map_data["sources"].map! do |s|
|
250
|
+
s.start_with?("file:") ? Addressable::URI.parse(s).route_from(source_root_url).to_s : s
|
251
|
+
end
|
252
|
+
JSON.generate(map_data)
|
253
|
+
end
|
254
|
+
|
255
|
+
# Adds the source-map to the source-map-page and adds it to `site.pages`.
|
256
|
+
def generate_source_map_page(source_map)
|
308
257
|
return if associate_page_failed?
|
309
258
|
|
310
|
-
source_map_page.source_map(
|
259
|
+
source_map_page.source_map(source_map)
|
311
260
|
site.pages << source_map_page
|
312
|
-
rescue ::SassC::NotRenderedError => e
|
313
|
-
Jekyll.logger.warn "Could not generate source map #{e.message} => #{e.cause}"
|
314
261
|
end
|
315
262
|
|
316
|
-
#
|
317
|
-
def
|
263
|
+
# Returns a source mapping url for given source-map.
|
264
|
+
def source_mapping_url
|
318
265
|
return if associate_page_failed?
|
319
266
|
|
320
|
-
|
321
|
-
map_data["file"] = Addressable::URI.encode(File.basename(output_path))
|
322
|
-
map_data["sources"].map! do |s|
|
323
|
-
s.start_with?("file:") ? Addressable::URI.parse(s).route_from(site_source_url) : s
|
324
|
-
end
|
325
|
-
|
326
|
-
source_map_page.source_map(JSON.generate(map_data))
|
327
|
-
site.pages << source_map_page
|
267
|
+
Addressable::URI.encode("#{sass_page.basename}.css.map")
|
328
268
|
end
|
329
269
|
|
330
270
|
def site
|
@@ -335,17 +275,33 @@ module Jekyll
|
|
335
275
|
site.source
|
336
276
|
end
|
337
277
|
|
338
|
-
def
|
339
|
-
|
340
|
-
Pathname.new(site_source).relative_path_from(Pathname.new(Dir.pwd)).to_s
|
278
|
+
def file_url_from_path(path)
|
279
|
+
Addressable::URI.encode("file://#{path.start_with?("/") ? "" : "/"}#{path}")
|
341
280
|
end
|
342
281
|
|
343
|
-
|
344
|
-
|
282
|
+
# Returns the value of the `quiet_deps`-option chosen by the user or 'false' by default.
|
283
|
+
def quiet_deps_option
|
284
|
+
!!jekyll_sass_configuration.fetch("quiet_deps", false)
|
345
285
|
end
|
346
286
|
|
347
|
-
|
348
|
-
|
287
|
+
# Returns the value of the `verbose`-option chosen by the user or 'false' by default.
|
288
|
+
def verbose_option
|
289
|
+
!!jekyll_sass_configuration.fetch("verbose", false)
|
290
|
+
end
|
291
|
+
|
292
|
+
# Returns the value of the `fatal_deprecations`-option or '[]' by default.
|
293
|
+
def fatal_deprecations
|
294
|
+
Array(jekyll_sass_configuration["fatal_deprecations"])
|
295
|
+
end
|
296
|
+
|
297
|
+
# Returns the value of the `future_deprecations`-option or '[]' by default.
|
298
|
+
def future_deprecations
|
299
|
+
Array(jekyll_sass_configuration["future_deprecations"])
|
300
|
+
end
|
301
|
+
|
302
|
+
# Returns the value of the `silence_deprecations`-option or '[]' by default.
|
303
|
+
def silence_deprecations
|
304
|
+
Array(jekyll_sass_configuration["silence_deprecations"])
|
349
305
|
end
|
350
306
|
end
|
351
307
|
end
|
metadata
CHANGED
@@ -1,92 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-sass-converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Moore
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.1
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '3.0'
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 2.0.1
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '3.0'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: bundler
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rake
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: rspec
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: rubocop-jekyll
|
14
|
+
name: sass-embedded
|
77
15
|
requirement: !ruby/object:Gem::Requirement
|
78
16
|
requirements:
|
79
17
|
- - "~>"
|
80
18
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
82
|
-
type: :
|
19
|
+
version: '1.75'
|
20
|
+
type: :runtime
|
83
21
|
prerelease: false
|
84
22
|
version_requirements: !ruby/object:Gem::Requirement
|
85
23
|
requirements:
|
86
24
|
- - "~>"
|
87
25
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
89
|
-
description:
|
26
|
+
version: '1.75'
|
27
|
+
description:
|
90
28
|
email:
|
91
29
|
- parkrmoore@gmail.com
|
92
30
|
executables: []
|
@@ -102,7 +40,7 @@ homepage: https://github.com/jekyll/jekyll-sass-converter
|
|
102
40
|
licenses:
|
103
41
|
- MIT
|
104
42
|
metadata: {}
|
105
|
-
post_install_message:
|
43
|
+
post_install_message:
|
106
44
|
rdoc_options: []
|
107
45
|
require_paths:
|
108
46
|
- lib
|
@@ -110,15 +48,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
48
|
requirements:
|
111
49
|
- - ">="
|
112
50
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
51
|
+
version: 3.1.0
|
114
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
53
|
requirements:
|
116
54
|
- - ">="
|
117
55
|
- !ruby/object:Gem::Version
|
118
56
|
version: '0'
|
119
57
|
requirements: []
|
120
|
-
rubygems_version: 3.
|
121
|
-
signing_key:
|
58
|
+
rubygems_version: 3.3.27
|
59
|
+
signing_key:
|
122
60
|
specification_version: 4
|
123
61
|
summary: A basic Sass converter for Jekyll.
|
124
62
|
test_files: []
|