Get rid of one trailing newline when preserve-ing text.
This commit is contained in:
parent
d085523f19
commit
ad2ed968de
|
@ -84,7 +84,7 @@ module Haml
|
|||
def preserve(input = '', &block)
|
||||
return preserve(capture_haml(&block)) if block
|
||||
|
||||
input.gsub(/\n/, '
').gsub(/\r/, '')
|
||||
input.chomp("\n").gsub(/\n/, '
').gsub(/\r/, '')
|
||||
end
|
||||
|
||||
alias_method :flatten, :preserve
|
||||
|
|
|
@ -141,12 +141,12 @@ class HelperTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_find_and_preserve_with_block
|
||||
assert_equal("<pre>
 Foo
 Bar
</pre>\nFoo\nBar\n",
|
||||
assert_equal("<pre>
 Foo
 Bar</pre>\nFoo\nBar\n",
|
||||
render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
|
||||
end
|
||||
|
||||
def test_preserve_with_block
|
||||
assert_equal("<pre>
 Foo
 Bar
</pre>
Foo
Bar
\n",
|
||||
assert_equal("<pre>
 Foo
 Bar
</pre>
Foo
Bar\n",
|
||||
render("= preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
|
||||
end
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ This
|
|||
\\
|
||||
<p>
|
||||
<pre>
|
||||
This pre is pretty deeply
 nested.
 Does interpolation work?

|
||||
This one is, too.
Nested, that is.


|
||||
This pre is pretty deeply
 nested.
 Does interpolation work?
|
||||
This one is, too.
Nested, that is.

|
||||
</pre>
|
||||
</p>
|
||||
<ul>
|
||||
|
|
|
@ -12,16 +12,16 @@
|
|||
<div class='text_area_test_area'>
|
||||
<textarea>Oneline</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
</textarea>
|
||||
<textarea>BLAH</textarea>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Two
lines</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
</textarea>
|
||||
<textarea>BLAH</textarea>
|
||||
<div id='flattened'>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Two
lines</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
</textarea>
|
||||
<textarea>BLAH</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class='hithere'>
|
||||
|
@ -36,7 +36,7 @@
|
|||
</div>
|
||||
<div class='foo'>
|
||||
13
|
||||
<textarea>
a
</textarea><textarea>
b
</textarea><textarea>
c
</textarea>
|
||||
<textarea>
a</textarea><textarea>
b</textarea><textarea>
c</textarea>
|
||||
</div>
|
||||
<div id='whitespace_test'>
|
||||
<div class='text_area_test_area'>
|
||||
|
@ -52,16 +52,16 @@
|
|||
<div class='text_area_test_area'>
|
||||
<textarea>Oneline</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
</textarea>
|
||||
<textarea>BLAH</textarea>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Two
lines</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
</textarea>
|
||||
<textarea>BLAH</textarea>
|
||||
<div id='flattened'>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Two
lines</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
</textarea>
|
||||
<textarea>BLAH</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class='hithere'>
|
||||
|
@ -74,11 +74,11 @@
|
|||
bar
|
||||
</p>
|
||||
<pre>
|
||||
___
 ,o88888
 ,o8888888'
 ,:o:o:oooo. ,8O88Pd8888"
 ,.::.::o:ooooOoOoO. ,oO8O8Pd888'"
 ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"
 , ..:.::o:ooOoOOOO8OOOOo.FdO8O8"
 , ..:.::o:ooOoOO8O888O8O,COCOO"
 , . ..:.::o:ooOoOOOO8OOOOCOCO"
 . ..:.::o:ooOoOoOO8O8OCCCC"o
 . ..:.::o:ooooOoCoCCC"o:o
 . ..:.::o:o:,cooooCo"oo:o:
 ` . . ..:.:cocoooo"'o:o:::'
 .` . ..::ccccoc"'o:o:o:::'
 :.:. ,c:cccc"':.:.:.:.:.'
 ..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/
 ...:.'.:.::::"' . . . . .'
 .. . ....:."' ` . . . ''
 . . . ...."'
 .. . ."' -hrr-
 .


 It's a planet!
%strong This shouldn't be bold!

|
||||
___
 ,o88888
 ,o8888888'
 ,:o:o:oooo. ,8O88Pd8888"
 ,.::.::o:ooooOoOoO. ,oO8O8Pd888'"
 ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"
 , ..:.::o:ooOoOOOO8OOOOo.FdO8O8"
 , ..:.::o:ooOoOO8O888O8O,COCOO"
 , . ..:.::o:ooOoOOOO8OOOOCOCO"
 . ..:.::o:ooOoOoOO8O8OCCCC"o
 . ..:.::o:ooooOoCoCCC"o:o
 . ..:.::o:o:,cooooCo"oo:o:
 ` . . ..:.:cocoooo"'o:o:::'
 .` . ..::ccccoc"'o:o:o:::'
 :.:. ,c:cccc"':.:.:.:.:.'
 ..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/
 ...:.'.:.::::"' . . . . .'
 .. . ....:."' ` . . . ''
 . . . ...."'
 .. . ."' -hrr-
 .


 It's a planet!
%strong This shouldn't be bold!
|
||||
</pre>
|
||||
<strong>This should!</strong>
|
||||
<textarea>
|
||||
___ ___ ___ ___ 
 /\__\ /\ \ /\__\ /\__\
 /:/ / /::\ \ /::| | /:/ /
 /:/__/ /:/\:\ \ /:|:| | /:/ / 
 /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / 
 /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ 
 \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ 
 \::/ / \::/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\__\
 \/__/ \/__/ \/__/ \/__/

 Many
 thanks
 to
 http://www.network-science.de/ascii/

|
||||
___ ___ ___ ___ 
 /\__\ /\ \ /\__\ /\__\
 /:/ / /::\ \ /::| | /:/ /
 /:/__/ /:/\:\ \ /:|:| | /:/ / 
 /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / 
 /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ 
 \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ 
 \::/ / \::/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\__\
 \/__/ \/__/ \/__/ \/__/

 Many
 thanks
 to
 http://www.network-science.de/ascii/
|
||||
<strong>indeed!</strong>
|
||||
</textarea>
|
||||
</div>
|
||||
|
@ -86,9 +86,9 @@
|
|||
13
|
||||
</div>
|
||||
<pre>
|
||||
__ ______ __ ______
.----.| |--.|__ |.----.| |--..--------.| __ |
| __|| ||__ || __|| < | || __ |
|____||__|__||______||____||__|__||__|__|__||______|

|
||||
__ ______ __ ______
.----.| |--.|__ |.----.| |--..--------.| __ |
| __|| ||__ || __|| < | || __ |
|____||__|__||______||____||__|__||__|__|__||______|
|
||||
</pre>
|
||||
<pre>
|
||||
foo

|
||||
foo
|
||||
bar
|
||||
</pre>
|
||||
|
|
Loading…
Reference in New Issue