Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extra newline in css output #144

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/jekyll/converters/scss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ def sass_configs

def convert(content)
output = ::Sass.compile_string(content, **sass_configs)
result = +"#{output.css}\n"
result = output.css

if sourcemap_required?
source_map = process_source_map(output.source_map)
generate_source_map_page(source_map)

if (sm_url = source_mapping_url)
result << "\n/*# sourceMappingURL=#{sm_url} */"
result += "\n/*# sourceMappingURL=#{sm_url} */"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to have blank line before the link to the sourcemap to serve as a visual separation from CSS rules, especially when the rules are compact.

Suggested change
result += "\n/*# sourceMappingURL=#{sm_url} */"
result += "\n\n/*# sourceMappingURL=#{sm_url} */"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/sass_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
end

let(:expanded_css_output) do
<<~CSS
<<~CSS.chomp
body {
font-family: Helvetica, sans-serif;
font-color: fuschia;
Expand Down Expand Up @@ -67,13 +67,13 @@ def converter(overrides = {})
it "does not include the charset without an associated page" do
overrides = { "style" => :expanded }
result = converter(overrides).convert(%(a\n content: "あ"))
expect(result).to eql(%(a {\n content: "あ";\n}\n))
expect(result).to eql(%(a {\n content: "あ";\n}))
end

it "does not include the BOM without an associated page" do
overrides = { "style" => :compressed }
result = converter(overrides).convert(%(a\n content: "あ"))
expect(result).to eql(%(a{content:"あ"}\n))
expect(result).to eql(%(a{content:"あ"}))
expect(result.bytes.to_a[0..2]).not_to eql([0xEF, 0xBB, 0xBF])
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/scss_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
end

let(:expanded_css_output) do
<<~CSS
<<~CSS.chomp
body {
font-family: Helvetica, sans-serif;
font-color: fuschia;
Expand Down Expand Up @@ -135,13 +135,13 @@ def converter(overrides = {})
it "does not include the charset without an associated page" do
overrides = { "style" => :expanded }
result = converter(overrides).convert(%(a{content:"あ"}))
expect(result).to eql(%(a {\n content: "あ";\n}\n))
expect(result).to eql(%(a {\n content: "あ";\n}))
end

it "does not include the BOM without an associated page" do
overrides = { "style" => :compressed }
result = converter(overrides).convert(%(a{content:"あ"}))
expect(result).to eql(%(a{content:"あ"}\n))
expect(result).to eql(%(a{content:"あ"}))
expect(result.bytes.to_a[0..2]).not_to eql([0xEF, 0xBB, 0xBF])
end
end
Expand All @@ -156,7 +156,7 @@ def converter(overrides = {})

it "imports SCSS partial" do
expect(File.read(test_css_file)).to eql(
".half{width:50%}\n\n/*# sourceMappingURL=main.css.map */"
".half{width:50%}\n/*# sourceMappingURL=main.css.map */"
)
end

Expand Down Expand Up @@ -195,7 +195,7 @@ def converter(overrides = {})
it "brings in the grid partial" do
site.process

expected = "a {\n color: #999999;\n}\n\n/*# sourceMappingURL=main.css.map */"
expected = "a {\n color: #999999;\n}\n/*# sourceMappingURL=main.css.map */"
expect(File.read(test_css_file)).to eql(expected)
end

Expand Down