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 whitespace when linebreaking quoted attributes. Closes #685 #729

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ a href=="&"
You can break quoted attributes with backslash `\`

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

#### Ruby attributes
Expand Down
2 changes: 1 addition & 1 deletion lib/slim/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,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