Skip to content

Commit

Permalink
add_charset false by default, but still strip BOM
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Dec 26, 2015
1 parent 3a6bf09 commit 4fc586b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
8 changes: 2 additions & 6 deletions lib/jekyll/converters/scss.rb
@@ -1,4 +1,4 @@
# encoding: utf-8:
# encoding: utf-8

require 'sass'
require 'jekyll/utils'
Expand Down Expand Up @@ -87,11 +87,7 @@ def allow_caching?
end

def add_charset?
if jekyll_sass_configuration["add_charset"].nil?
true
else
jekyll_sass_configuration["add_charset"]
end
!!jekyll_sass_configuration["add_charset"]
end

def sass_configs
Expand Down
6 changes: 3 additions & 3 deletions spec/sass_converter_spec.rb
Expand Up @@ -56,13 +56,13 @@ def converter(overrides = {})

it "removes byte order mark from compressed Sass" do
result = converter({ "style" => :compressed }).convert("a\n content: \"\uF015\"")
expect(result).to eql("@charset \"UTF-8\";a{content:\"\uF015\"}\n")
expect(result).to eql("a{content:\"\uF015\"}\n")
expect(result.bytes.to_a[0..2]).not_to eql([0xEF, 0xBB, 0xBF])
end

it "does not include the charset if asked not to" do
result = converter({ "style" => :compressed, "add_charset" => false }).convert("a\n content: \"\uF015\"")
expect(result).to eql("a{content:\"\uF015\"}\n")
result = converter({ "style" => :compressed, "add_charset" => true }).convert("a\n content: \"\uF015\"")
expect(result).to eql("@charset \"UTF-8\";a{content:\"\uF015\"}\n")
expect(result.bytes.to_a[0..2]).not_to eql([0xEF, 0xBB, 0xBF])
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/scss_converter_spec.rb
Expand Up @@ -125,13 +125,13 @@ def converter(overrides = {})

it "removes byte order mark from compressed SCSS" do
result = converter({ "style" => :compressed }).convert("a{content:\"\uF015\"}")
expect(result).to eql("@charset \"UTF-8\";a{content:\"\uF015\"}\n")
expect(result).to eql("a{content:\"\uF015\"}\n")
expect(result.bytes.to_a[0..2]).not_to eql([0xEF, 0xBB, 0xBF])
end

it "does not include the charset if asked not to" do
result = converter({ "style" => :compressed, "add_charset" => false }).convert("a{content:\"\uF015\"}")
expect(result).to eql("a{content:\"\uF015\"}\n")
it "does not include the charset unless asked to" do
result = converter({ "style" => :compressed, "add_charset" => true }).convert("a{content:\"\uF015\"}")
expect(result).to eql("@charset \"UTF-8\";a{content:\"\uF015\"}\n")
expect(result.bytes.to_a[0..2]).not_to eql([0xEF, 0xBB, 0xBF])
end
end
Expand Down

0 comments on commit 4fc586b

Please sign in to comment.