Skip to content

Commit

Permalink
Just like HAML tends to do, filters content must be rstrip
Browse files Browse the repository at this point in the history
This avoids the bloc of code being showing extra blank lines at the end
  • Loading branch information
MaxLap committed Nov 28, 2020
1 parent ad7bcde commit 92f20f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- Fixed HAML :code filter to remove trailing blank lines

# 3.2.0

- Prep for Middleman v5
Expand Down
12 changes: 12 additions & 0 deletions features/haml_filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ Feature: Haml :code filter.
When I go to "/code_haml_filter.html"
Then I should see '<span class="k">def</span>'
Then I should see '<pre class="highlight plaintext"><code>This is some code'

Scenario: Filter doesn't keep trailing blank lines
Given a fixture app "test-app"
And a file named "config.rb" with:
"""
set :haml, { :ugly => false }
activate :syntax
"""
Given the Server is running at "test-app"
When I go to "/code_haml_filter.html"
Then I should see '<span class="k">def</span>'
Then I should see '<pre class="highlight plaintext"><code>This is some code</code></pre>'
1 change: 1 addition & 0 deletions lib/middleman-syntax/haml_monkey_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Code
include Base

def render(code)
code = code.rstrip
code = code.encode(Encoding::UTF_8)

# Allow language to be specified via a special comment like:
Expand Down

0 comments on commit 92f20f1

Please sign in to comment.