Skip to content

Commit

Permalink
Remove whitespace when linebreaking quoted attributes. Closes slim-te…
Browse files Browse the repository at this point in the history
  • Loading branch information
Inversion-des committed Jan 8, 2018
1 parent da17e17 commit 650dea2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ a href=="&"
You can break quoted attributes with backslash `\`

~~~ slim
a data-title="help" data-content="extremely long help text that goes on\
a data-title="help" data-content="extremely long help text that goes on \
and on and on and then starts over...."
~~~

Expand Down
2 changes: 1 addition & 1 deletion lib/slim/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def parse_quoted_attribute(quote)

until count == 0 && @line[0] == quote[0]
if @line =~ /\A(\\)?\Z/
value << ($1 ? ' ' : "\n")
value << ($1 ? '' : "\n")
expect_next_line
else
if @line[0] == ?{
Expand Down
10 changes: 5 additions & 5 deletions test/literate/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -944,27 +944,27 @@ You can use newlines in quoted attributes

~~~ slim
a data-title="help" data-content="extremely long help text that goes on
and one and one and then starts over...." Link
and on and on and then starts over...." Link
~~~

renders as

~~~ html
<a data-content="extremely long help text that goes on
and one and one and then starts over...." data-title="help">Link</a>
and on and on and then starts over...." data-title="help">Link</a>
~~~

You can break quoted attributes with an backslash `\`

~~~ slim
a data-title="help" data-content="extremely long help text that goes on\
and one and one and then starts over...." Link
a data-title="help" data-content="extremely long help text that goes on \
and on and on and then starts over...." Link
~~~

renders as

~~~ html
<a data-content="extremely long help text that goes on and one and one and then starts over...." data-title="help">Link</a>
<a data-content="extremely long help text that goes on and on and on and then starts over...." data-title="help">Link</a>
~~~

#### Ruby attributes
Expand Down

0 comments on commit 650dea2

Please sign in to comment.