sablon 0.0.19.beta1 → 0.0.19.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sablon/html/converter.rb +4 -1
- data/lib/sablon/version.rb +1 -1
- data/test/fixtures/html_sample.docx +0 -0
- data/test/html/converter_test.rb +13 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d201139ea7689ee5ece96bdb890b1241714863a
|
4
|
+
data.tar.gz: 43073c128829d00d470669b734ecae7430aaaed6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 822d41137b73c13abd5102b757f9de9814c822fcb0cffde2e57b0bfc07a978791a5f6d2119671e479cc7aa44a4cd9a616ac4df8e1a8f6f76c0bd357ee6968bcb
|
7
|
+
data.tar.gz: 48a8398f40eebe6df13967b37a413702bee477d245b9c93a7d4375c4be51c39639d861fc18614453a71d5f8ccc71d081457057bb07a9c3f2d4b9c65cea7edc19
|
data/Gemfile.lock
CHANGED
@@ -85,7 +85,10 @@ module Sablon
|
|
85
85
|
private
|
86
86
|
def ast_next_paragraph
|
87
87
|
node = @builder.next
|
88
|
-
if node.name == 'div'
|
88
|
+
if node.name == 'div'
|
89
|
+
@builder.new_layer
|
90
|
+
@builder.emit Paragraph.new('Normal', text(node.children))
|
91
|
+
elsif node.name == 'p'
|
89
92
|
@builder.new_layer
|
90
93
|
@builder.emit Paragraph.new('Paragraph', text(node.children))
|
91
94
|
elsif node.name == 'ul'
|
data/lib/sablon/version.rb
CHANGED
Binary file
|
data/test/html/converter_test.rb
CHANGED
@@ -11,7 +11,7 @@ class HTMLConverterTest < Sablon::TestCase
|
|
11
11
|
input = '<div>Lorem ipsum dolor sit amet</div>'
|
12
12
|
expected_output = <<-DOCX.strip
|
13
13
|
<w:p>
|
14
|
-
<w:pPr><w:pStyle w:val="
|
14
|
+
<w:pPr><w:pStyle w:val="Normal" /></w:pPr>
|
15
15
|
<w:r><w:t xml:space="preserve">Lorem ipsum dolor sit amet</w:t></w:r>
|
16
16
|
</w:p>
|
17
17
|
DOCX
|
@@ -33,11 +33,11 @@ DOCX
|
|
33
33
|
input = '<div>Lorem ipsum</div><div>dolor sit amet</div>'
|
34
34
|
expected_output = <<-DOCX.strip
|
35
35
|
<w:p>
|
36
|
-
<w:pPr><w:pStyle w:val="
|
36
|
+
<w:pPr><w:pStyle w:val="Normal" /></w:pPr>
|
37
37
|
<w:r><w:t xml:space="preserve">Lorem ipsum</w:t></w:r>
|
38
38
|
</w:p>
|
39
39
|
<w:p>
|
40
|
-
<w:pPr><w:pStyle w:val="
|
40
|
+
<w:pPr><w:pStyle w:val="Normal" /></w:pPr>
|
41
41
|
<w:r><w:t xml:space="preserve">dolor sit amet</w:t></w:r>
|
42
42
|
</w:p>
|
43
43
|
DOCX
|
@@ -48,7 +48,7 @@ DOCX
|
|
48
48
|
input = '<div>Lorem ipsum<br>dolor sit amet</div>'
|
49
49
|
expected_output = <<-DOCX.strip
|
50
50
|
<w:p>
|
51
|
-
<w:pPr><w:pStyle w:val="
|
51
|
+
<w:pPr><w:pStyle w:val="Normal" /></w:pPr>
|
52
52
|
<w:r><w:t xml:space="preserve">Lorem ipsum</w:t></w:r>
|
53
53
|
<w:r><w:br/></w:r>
|
54
54
|
<w:r><w:t xml:space="preserve">dolor sit amet</w:t></w:r>
|
@@ -61,7 +61,7 @@ DOCX
|
|
61
61
|
input = '<div>Lorem <strong>ipsum dolor</strong> sit amet</div>'
|
62
62
|
expected_output = <<-DOCX.strip
|
63
63
|
<w:p>
|
64
|
-
<w:pPr><w:pStyle w:val="
|
64
|
+
<w:pPr><w:pStyle w:val="Normal" /></w:pPr>
|
65
65
|
<w:r><w:t xml:space="preserve">Lorem </w:t></w:r>
|
66
66
|
<w:r><w:rPr><w:b /></w:rPr><w:t xml:space="preserve">ipsum dolor</w:t></w:r>
|
67
67
|
<w:r><w:t xml:space="preserve"> sit amet</w:t></w:r>
|
@@ -74,7 +74,7 @@ DOCX
|
|
74
74
|
input = '<div>Lorem <em>ipsum dolor</em> sit amet</div>'
|
75
75
|
expected_output = <<-DOCX.strip
|
76
76
|
<w:p>
|
77
|
-
<w:pPr><w:pStyle w:val="
|
77
|
+
<w:pPr><w:pStyle w:val="Normal" /></w:pPr>
|
78
78
|
<w:r><w:t xml:space="preserve">Lorem </w:t></w:r>
|
79
79
|
<w:r><w:rPr><w:i /></w:rPr><w:t xml:space="preserve">ipsum dolor</w:t></w:r>
|
80
80
|
<w:r><w:t xml:space="preserve"> sit amet</w:t></w:r>
|
@@ -265,9 +265,15 @@ class HTMLConverterASTTest < Sablon::TestCase
|
|
265
265
|
input = '<div>Lorem ipsum dolor sit amet</div>'
|
266
266
|
ast = @converter.processed_ast(input).to_a
|
267
267
|
assert_equal [Sablon::HTMLConverter::Paragraph], ast.map(&:class)
|
268
|
-
assert_equal ['
|
268
|
+
assert_equal ['Normal'], ast.map(&:style)
|
269
269
|
end
|
270
270
|
|
271
|
+
def test_p
|
272
|
+
input = '<p>Lorem ipsum dolor sit amet</p>'
|
273
|
+
ast = @converter.processed_ast(input).to_a
|
274
|
+
assert_equal [Sablon::HTMLConverter::Paragraph], ast.map(&:class)
|
275
|
+
assert_equal ['Paragraph'], ast.map(&:style)
|
276
|
+
end
|
271
277
|
|
272
278
|
def test_ul
|
273
279
|
input = '<ul><li>Lorem</li><li>ipsum</li></ul>'
|