mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Haml] [html2haml] Properly convert inline formatting.
This commit is contained in:
parent
32161b1b5c
commit
09d277a7ae
3 changed files with 51 additions and 0 deletions
|
@ -3,6 +3,11 @@
|
|||
* Table of contents
|
||||
{:toc}
|
||||
|
||||
## 3.0.0 (Unreleased)
|
||||
|
||||
* When converting HTML with inline formatting to Haml via `html2haml`,
|
||||
use `>` or {Haml::Helpers#succeed #succeed} where necessary.
|
||||
|
||||
## 3.0.0.rc.5
|
||||
|
||||
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0.rc.5).
|
||||
|
|
|
@ -279,6 +279,18 @@ module Haml
|
|||
end
|
||||
end
|
||||
|
||||
if self.next && self.next.text? && self.next.content =~ /\A[^\s]/
|
||||
if self.previous.nil? || self.previous.text? &&
|
||||
(self.previous.content =~ /[^\s]\Z/ ||
|
||||
self.previous.content =~ /\A\s*\Z/ && self.previous.previous.nil?)
|
||||
nuke_outer_whitespace = true
|
||||
else
|
||||
output << "- succeed #{self.next.content.slice!(/\A[^\s]+/).dump} do\n"
|
||||
tabs += 1
|
||||
output << tabulate(tabs)
|
||||
end
|
||||
end
|
||||
|
||||
output << "%#{name}" unless name == 'div' &&
|
||||
(static_id?(options) ||
|
||||
static_classname?(options) &&
|
||||
|
@ -300,6 +312,7 @@ module Haml
|
|||
output << haml_attributes(options) if attr_hash.length > 0
|
||||
end
|
||||
|
||||
output << ">" if nuke_outer_whitespace
|
||||
output << "/" if empty? && !etag
|
||||
|
||||
if children && children.size == 1
|
||||
|
|
|
@ -246,6 +246,39 @@ HTML
|
|||
assert_equal("%p # foo bar #", render("<p># foo bar #</p>"))
|
||||
end
|
||||
|
||||
def test_comma_post_tag
|
||||
assert_equal(<<HAML.rstrip, render(<<HTML))
|
||||
#foo
|
||||
%span> Foo
|
||||
,
|
||||
%span bar
|
||||
Foo
|
||||
%span> bar
|
||||
,
|
||||
%span baz
|
||||
HAML
|
||||
<div id="foo">
|
||||
<span>Foo</span>, <span>bar</span>
|
||||
Foo<span>bar</span>, <span>baz</span>
|
||||
</div>
|
||||
HTML
|
||||
end
|
||||
|
||||
def test_comma_post_tag_with_text_before
|
||||
assert_equal(<<HAML.rstrip, render(<<HTML))
|
||||
#foo
|
||||
Batch
|
||||
- succeed "," do
|
||||
%span Foo
|
||||
%span Bar
|
||||
HAML
|
||||
<div id="foo">
|
||||
Batch
|
||||
<span>Foo</span>, <span>Bar</span>
|
||||
</div>
|
||||
HTML
|
||||
end
|
||||
|
||||
begin
|
||||
require 'haml/html/erb'
|
||||
include ErbTests
|
||||
|
|
Loading…
Reference in a new issue