sablon 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +36 -5
  4. data/lib/sablon.rb +0 -3
  5. data/lib/sablon/configuration/html_tag.rb +1 -1
  6. data/lib/sablon/content.rb +56 -0
  7. data/lib/sablon/context.rb +2 -0
  8. data/lib/sablon/document_object_model/content_types.rb +35 -0
  9. data/lib/sablon/document_object_model/file_handler.rb +26 -0
  10. data/lib/sablon/document_object_model/model.rb +94 -0
  11. data/lib/sablon/document_object_model/numbering.rb +94 -0
  12. data/lib/sablon/document_object_model/relationships.rb +111 -0
  13. data/lib/sablon/environment.rb +13 -16
  14. data/lib/sablon/html/ast.rb +14 -13
  15. data/lib/sablon/html/ast_builder.rb +18 -5
  16. data/lib/sablon/html/node_properties.rb +3 -3
  17. data/lib/sablon/operations.rb +59 -0
  18. data/lib/sablon/processor/document.rb +48 -11
  19. data/lib/sablon/processor/section_properties.rb +11 -4
  20. data/lib/sablon/template.rb +88 -47
  21. data/lib/sablon/version.rb +1 -1
  22. data/misc/image-example.png +0 -0
  23. data/test/configuration_test.rb +22 -22
  24. data/test/content_test.rb +50 -0
  25. data/test/context_test.rb +37 -1
  26. data/test/environment_test.rb +4 -1
  27. data/test/executable_test.rb +0 -2
  28. data/test/fixtures/cv_sample.docx +0 -0
  29. data/test/fixtures/html_sample.docx +0 -0
  30. data/test/fixtures/images/c3po.jpg +0 -0
  31. data/test/fixtures/images/clone.jpg +0 -0
  32. data/test/fixtures/images/darth_vader.jpg +0 -0
  33. data/test/fixtures/images/r2d2.jpg +0 -0
  34. data/test/fixtures/images_sample.docx +0 -0
  35. data/test/fixtures/images_template.docx +0 -0
  36. data/test/fixtures/loops_sample.docx +0 -0
  37. data/test/fixtures/loops_template.docx +0 -0
  38. data/test/fixtures/recipe_sample.docx +0 -0
  39. data/test/fixtures/xml/image.xml +91 -0
  40. data/test/fixtures/xml/loop_with_unique_ids.xml +152 -0
  41. data/test/fixtures/xml/mock_document/word/document.xml +12 -0
  42. data/test/html/ast_test.rb +10 -5
  43. data/test/html/converter_style_test.rb +9 -9
  44. data/test/html/converter_test.rb +66 -81
  45. data/test/html/node_properties_test.rb +2 -2
  46. data/test/html_test.rb +2 -6
  47. data/test/processor/document_test.rb +80 -3
  48. data/test/processor/section_properties_test.rb +68 -0
  49. data/test/sablon_test.rb +77 -5
  50. data/test/test_helper.rb +109 -9
  51. metadata +33 -9
  52. data/lib/sablon/numbering.rb +0 -23
  53. data/lib/sablon/processor/numbering.rb +0 -47
  54. data/lib/sablon/relationship.rb +0 -47
  55. data/lib/sablon/test/assertions.rb +0 -22
  56. data/test/section_properties_test.rb +0 -41
@@ -0,0 +1,152 @@
1
+ <w:p>
2
+ <w:pPr>
3
+ <w:rPr>
4
+ <w:noProof/>
5
+ </w:rPr>
6
+ </w:pPr>
7
+ </w:p>
8
+ <w:p>
9
+ <w:pPr>
10
+ <w:rPr>
11
+ <w:noProof/>
12
+ </w:rPr>
13
+ </w:pPr>
14
+ </w:p>
15
+ <w:p>
16
+ <w:r>
17
+ <w:fldChar w:fldCharType="begin"/>
18
+ </w:r>
19
+ <w:r>
20
+ <w:instrText xml:space="preserve"> MERGEFIELD </w:instrText>
21
+ </w:r>
22
+ <w:r>
23
+ <w:instrText>cars</w:instrText>
24
+ </w:r>
25
+ <w:r>
26
+ <w:instrText xml:space="preserve">:each(item) \* MERGEFORMAT </w:instrText>
27
+ </w:r>
28
+ <w:r>
29
+ <w:fldChar w:fldCharType="separate"/>
30
+ </w:r>
31
+ <w:r>
32
+ <w:rPr>
33
+ <w:noProof/>
34
+ </w:rPr>
35
+ <w:t>«cars:each(item)»</w:t>
36
+ </w:r>
37
+ <w:r>
38
+ <w:rPr>
39
+ <w:noProof/>
40
+ </w:rPr>
41
+ <w:fldChar w:fldCharType="end"/>
42
+ </w:r>
43
+ </w:p>
44
+ <w:p>
45
+ <w:pPr>
46
+ <w:pStyle w:val="ListParagraph"/>
47
+ <w:numPr>
48
+ <w:ilvl w:val="0"/>
49
+ <w:numId w:val="1"/>
50
+ </w:numPr>
51
+ </w:pPr>
52
+ <w:r>
53
+ <w:fldChar w:fldCharType="begin"/>
54
+ </w:r>
55
+ <w:r>
56
+ <w:instrText xml:space="preserve"> MERGEFIELD =item.name \* MERGEFORMAT </w:instrText>
57
+ </w:r>
58
+ <w:r>
59
+ <w:fldChar w:fldCharType="separate"/>
60
+ </w:r>
61
+ <w:r>
62
+ <w:rPr>
63
+ <w:noProof/>
64
+ </w:rPr>
65
+ <w:t>«=item.name»</w:t>
66
+ </w:r>
67
+ <w:r>
68
+ <w:fldChar w:fldCharType="end"/>
69
+ </w:r>
70
+ <w:r>
71
+ <w:t xml:space="preserve">
72
+ </w:t>
73
+ </w:r>
74
+ <w:r>
75
+ <w:rPr>
76
+ <w:noProof/>
77
+ </w:rPr>
78
+ <w:drawing>
79
+ <wp:inline distT="0" distB="0" distL="0" distR="0">
80
+ <wp:extent cx="1254868" cy="889278"/>
81
+ <wp:effectExtent l="0" t="0" r="2540" b="0"/>
82
+ <wp:docPr id="2" name="Picture 3"/>
83
+ <wp:cNvGraphicFramePr>
84
+ <a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
85
+ </wp:cNvGraphicFramePr>
86
+ <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
87
+ <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
88
+ <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
89
+ <pic:nvPicPr>
90
+ <pic:cNvPr id="3" name="MTF 500.pdf"/>
91
+ <pic:cNvPicPr/>
92
+ </pic:nvPicPr>
93
+ <pic:blipFill>
94
+ <a:blip r:embed="rId5" cstate="print">
95
+ <a:extLst>
96
+ <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
97
+ <a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
98
+ </a:ext>
99
+ </a:extLst>
100
+ </a:blip>
101
+ <a:stretch>
102
+ <a:fillRect/>
103
+ </a:stretch>
104
+ </pic:blipFill>
105
+ <pic:spPr>
106
+ <a:xfrm>
107
+ <a:off x="0" y="0"/>
108
+ <a:ext cx="1286502" cy="911696"/>
109
+ </a:xfrm>
110
+ <a:prstGeom prst="rect">
111
+ <a:avLst/>
112
+ </a:prstGeom>
113
+ </pic:spPr>
114
+ </pic:pic>
115
+ </a:graphicData>
116
+ </a:graphic>
117
+ </wp:inline>
118
+ </w:drawing>
119
+ </w:r>
120
+ <w:r>
121
+ <w:br/>
122
+ </w:r>
123
+ </w:p>
124
+ <w:p>
125
+ <w:r>
126
+ <w:fldChar w:fldCharType="begin"/>
127
+ </w:r>
128
+ <w:r>
129
+ <w:instrText xml:space="preserve"> MERGEFIELD </w:instrText>
130
+ </w:r>
131
+ <w:r>
132
+ <w:instrText>cars</w:instrText>
133
+ </w:r>
134
+ <w:r>
135
+ <w:instrText xml:space="preserve">:endEach \* MERGEFORMAT </w:instrText>
136
+ </w:r>
137
+ <w:r>
138
+ <w:fldChar w:fldCharType="separate"/>
139
+ </w:r>
140
+ <w:r>
141
+ <w:rPr>
142
+ <w:noProof/>
143
+ </w:rPr>
144
+ <w:t>«cars:endEach»</w:t>
145
+ </w:r>
146
+ <w:r>
147
+ <w:rPr>
148
+ <w:noProof/>
149
+ </w:rPr>
150
+ <w:fldChar w:fldCharType="end"/>
151
+ </w:r>
152
+ </w:p>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 wp14">
3
+ <w:body>
4
+ <w:p></w:p>
5
+ <w:sectPr>
6
+ <w:pgSz w:w="12240" w:h="15840"/>
7
+ <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/>
8
+ <w:cols w:space="720"/>
9
+ <w:docGrid w:linePitch="360"/>
10
+ </w:sectPr>
11
+ </w:body>
12
+ </w:document>
@@ -1,12 +1,17 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require "test_helper"
3
- require 'securerandom'
4
3
 
5
4
  class HTMLConverterASTTest < Sablon::TestCase
6
5
  def setup
7
6
  super
7
+ @template = MockTemplate.new
8
+ @env = Sablon::Environment.new(@template)
8
9
  @converter = Sablon::HTMLConverter.new
9
- @converter.instance_variable_set(:@env, Sablon::Environment.new(nil))
10
+ @converter.instance_variable_set(:@env, @env)
11
+ end
12
+
13
+ def teardown
14
+ @template.document.reset
10
15
  end
11
16
 
12
17
  def test_div
@@ -95,18 +100,18 @@ class HTMLConverterASTTest < Sablon::TestCase
95
100
 
96
101
  def test_num_id
97
102
  ast = @converter.processed_ast('<ol><li>Some</li><li>Lorem</li></ol><ul><li>ipsum</li></ul><ol><li>dolor</li><li>sit</li></ol>')
98
- assert_equal %w[1001 1001 1002 1003 1003], get_numpr_prop_from_ast(ast, :numId)
103
+ assert_equal %w[1 1 2 3 3], get_numpr_prop_from_ast(ast, :numId)
99
104
  end
100
105
 
101
106
  def test_nested_lists_have_the_same_numid
102
107
  ast = @converter.processed_ast('<ul><li>Lorem<ul><li>ipsum<ul><li>dolor</li></ul></li></ul></li></ul>')
103
- assert_equal %w[1001 1001 1001], get_numpr_prop_from_ast(ast, :numId)
108
+ assert_equal %w[1 1 1], get_numpr_prop_from_ast(ast, :numId)
104
109
  end
105
110
 
106
111
  def test_keep_nested_list_order
107
112
  input = '<ul><li>1<ul><li>1.1<ul><li>1.1.1</li></ul></li><li>1.2</li></ul></li><li>2<ul><li>1.3<ul><li>1.3.1</li></ul></li></ul></li></ul>'
108
113
  ast = @converter.processed_ast(input)
109
- assert_equal %w[1001], get_numpr_prop_from_ast(ast, :numId).uniq
114
+ assert_equal %w[1], get_numpr_prop_from_ast(ast, :numId).uniq
110
115
  assert_equal %w[0 1 2 1 0 1 2], get_numpr_prop_from_ast(ast, :ilvl)
111
116
  end
112
117
 
@@ -4,10 +4,15 @@ require "test_helper"
4
4
  class HTMLConverterStyleTest < Sablon::TestCase
5
5
  def setup
6
6
  super
7
- @env = Sablon::Environment.new(nil)
7
+ @template = MockTemplate.new
8
+ @env = Sablon::Environment.new(@template)
8
9
  @converter = Sablon::HTMLConverter.new
9
10
  end
10
11
 
12
+ def teardown
13
+ @template.document.reset
14
+ end
15
+
11
16
  # testing direct CSS style -> WordML conversion for paragraphs
12
17
 
13
18
  def test_paragraph_with_background_color
@@ -75,14 +80,9 @@ class HTMLConverterStyleTest < Sablon::TestCase
75
80
 
76
81
  # test that styles defined on the <a> tag are passed down to runs
77
82
  def test_hyperlink_with_font_style
78
- uid_generator = UIDTestGenerator.new
79
- SecureRandom.stub(:uuid, uid_generator.method(:new_uid)) do |secure_random_instance|
80
- uid_generator.reset
81
- input = '<p><a href="http://www.google.com" style="font-style: italic">Google</a></p>'
82
- expected_output = hyperlink_with_rpr('<w:i />', secure_random_instance.uuid)
83
- uid_generator.reset
84
- assert_equal normalize_wordml(expected_output), process(input)
85
- end
83
+ input = '<p><a href="http://www.google.com" style="font-style: italic">Google</a></p>'
84
+ expected_output = hyperlink_with_rpr('<w:i />', @template.document.current_rid + 1)
85
+ assert_equal normalize_wordml(expected_output), process(input)
86
86
  end
87
87
 
88
88
  def test_run_with_background_color
@@ -4,11 +4,15 @@ require "test_helper"
4
4
  class HTMLConverterTest < Sablon::TestCase
5
5
  def setup
6
6
  super
7
- @env = Sablon::Environment.new(nil)
8
- @numbering = @env.numbering
7
+ @template = MockTemplate.new
8
+ @env = Sablon::Environment.new(@template)
9
9
  @converter = Sablon::HTMLConverter.new
10
10
  end
11
11
 
12
+ def teardown
13
+ @template.document.reset
14
+ end
15
+
12
16
  def test_convert_text_inside_div
13
17
  input = '<div>Lorem ipsum dolor sit amet</div>'
14
18
  expected_output = <<-DOCX.strip
@@ -32,50 +36,41 @@ class HTMLConverterTest < Sablon::TestCase
32
36
  end
33
37
 
34
38
  def test_convert_hyperlink_inside_div
35
- uid_generator = UIDTestGenerator.new
36
- SecureRandom.stub(:uuid, uid_generator.method(:new_uid)) do |secure_random_instance|
37
-
38
- input = '<div>Lorem ipsum dolor sit amet; search it at <a href="http://www.google.com">google</a></div>'
39
- expected_output = <<-DOCX.strip
40
- <w:p>
41
- <w:pPr><w:pStyle w:val="Normal" /></w:pPr>
42
- <w:r><w:t xml:space="preserve">Lorem ipsum dolor sit amet; search it at </w:t></w:r>
43
- <w:hyperlink r:id=\"rId#{secure_random_instance.uuid}\">
44
- <w:r>
45
- <w:rPr>
46
- <w:rStyle w:val=\"Hyperlink\" />
47
- </w:rPr>
48
- <w:t xml:space=\"preserve\">google</w:t>
49
- </w:r>
50
- </w:hyperlink>
51
- </w:p>
52
- DOCX
53
- uid_generator.reset
54
- assert_equal normalize_wordml(expected_output), process(input)
55
- end
39
+ input = '<div>Lorem ipsum dolor sit amet; search it at <a href="http://www.google.com">google</a></div>'
40
+ expected_output = <<-DOCX.strip
41
+ <w:p>
42
+ <w:pPr><w:pStyle w:val="Normal" /></w:pPr>
43
+ <w:r><w:t xml:space="preserve">Lorem ipsum dolor sit amet; search it at </w:t></w:r>
44
+ <w:hyperlink r:id=\"rId#{@template.document.current_rid + 1}\">
45
+ <w:r>
46
+ <w:rPr>
47
+ <w:rStyle w:val=\"Hyperlink\" />
48
+ </w:rPr>
49
+ <w:t xml:space=\"preserve\">google</w:t>
50
+ </w:r>
51
+ </w:hyperlink>
52
+ </w:p>
53
+ DOCX
54
+ assert_equal normalize_wordml(expected_output), process(input)
56
55
  end
57
56
 
58
57
  def test_convert_hyperlink_inside_p
59
- uid_generator = UIDTestGenerator.new
60
- SecureRandom.stub(:uuid, uid_generator.method(:new_uid)) do |secure_random_instance|
61
- input = '<p>Lorem ipsum dolor sit amet; search it at <a href="http://www.google.com">google</a></p>'
62
- expected_output = <<-DOCX.strip
63
- <w:p>
64
- <w:pPr><w:pStyle w:val="Paragraph" /></w:pPr>
65
- <w:r><w:t xml:space="preserve">Lorem ipsum dolor sit amet; search it at </w:t></w:r>
66
- <w:hyperlink r:id=\"rId#{secure_random_instance.uuid}\">
67
- <w:r>
68
- <w:rPr>
69
- <w:rStyle w:val=\"Hyperlink\" />
70
- </w:rPr>
71
- <w:t xml:space=\"preserve\">google</w:t>
72
- </w:r>
73
- </w:hyperlink>
74
- </w:p>
75
- DOCX
76
- uid_generator.reset
77
- assert_equal normalize_wordml(expected_output), process(input)
78
- end
58
+ input = '<p>Lorem ipsum dolor sit amet; search it at <a href="http://www.google.com">google</a></p>'
59
+ expected_output = <<-DOCX.strip
60
+ <w:p>
61
+ <w:pPr><w:pStyle w:val="Paragraph" /></w:pPr>
62
+ <w:r><w:t xml:space="preserve">Lorem ipsum dolor sit amet; search it at </w:t></w:r>
63
+ <w:hyperlink r:id=\"rId#{@template.document.current_rid + 1}\">
64
+ <w:r>
65
+ <w:rPr>
66
+ <w:rStyle w:val=\"Hyperlink\" />
67
+ </w:rPr>
68
+ <w:t xml:space=\"preserve\">google</w:t>
69
+ </w:r>
70
+ </w:hyperlink>
71
+ </w:p>
72
+ DOCX
73
+ assert_equal normalize_wordml(expected_output), process(input)
79
74
  end
80
75
 
81
76
  def test_convert_text_inside_multiple_divs
@@ -247,7 +242,7 @@ class HTMLConverterTest < Sablon::TestCase
247
242
  <w:pStyle w:val="ListBullet" />
248
243
  <w:numPr>
249
244
  <w:ilvl w:val="0" />
250
- <w:numId w:val="1001" />
245
+ <w:numId w:val="1" />
251
246
  </w:numPr>
252
247
  </w:pPr>
253
248
  <w:r><w:t xml:space="preserve">Lorem</w:t></w:r>
@@ -258,7 +253,7 @@ class HTMLConverterTest < Sablon::TestCase
258
253
  <w:pStyle w:val="ListBullet" />
259
254
  <w:numPr>
260
255
  <w:ilvl w:val="0" />
261
- <w:numId w:val="1001" />
256
+ <w:numId w:val="1" />
262
257
  </w:numPr>
263
258
  </w:pPr>
264
259
  <w:r><w:t xml:space="preserve">ipsum</w:t></w:r>
@@ -269,14 +264,13 @@ class HTMLConverterTest < Sablon::TestCase
269
264
  <w:pStyle w:val="ListBullet" />
270
265
  <w:numPr>
271
266
  <w:ilvl w:val="0" />
272
- <w:numId w:val="1001" />
267
+ <w:numId w:val="1" />
273
268
  </w:numPr>
274
269
  </w:pPr>
275
270
  <w:r><w:t xml:space="preserve">dolor</w:t></w:r>
276
271
  </w:p>
277
272
  DOCX
278
273
  assert_equal normalize_wordml(expected_output), process(input)
279
- assert_equal [Sablon::Numbering::Definition.new(1001, 'ListBullet')], @numbering.definitions
280
274
  end
281
275
 
282
276
  def test_ordered_lists
@@ -287,7 +281,7 @@ class HTMLConverterTest < Sablon::TestCase
287
281
  <w:pStyle w:val="ListNumber" />
288
282
  <w:numPr>
289
283
  <w:ilvl w:val="0" />
290
- <w:numId w:val="1001" />
284
+ <w:numId w:val="1" />
291
285
  </w:numPr>
292
286
  </w:pPr>
293
287
  <w:r><w:t xml:space="preserve">Lorem</w:t></w:r>
@@ -298,7 +292,7 @@ class HTMLConverterTest < Sablon::TestCase
298
292
  <w:pStyle w:val="ListNumber" />
299
293
  <w:numPr>
300
294
  <w:ilvl w:val="0" />
301
- <w:numId w:val="1001" />
295
+ <w:numId w:val="1" />
302
296
  </w:numPr>
303
297
  </w:pPr>
304
298
  <w:r><w:t xml:space="preserve">ipsum</w:t></w:r>
@@ -309,14 +303,13 @@ class HTMLConverterTest < Sablon::TestCase
309
303
  <w:pStyle w:val="ListNumber" />
310
304
  <w:numPr>
311
305
  <w:ilvl w:val="0" />
312
- <w:numId w:val="1001" />
306
+ <w:numId w:val="1" />
313
307
  </w:numPr>
314
308
  </w:pPr>
315
309
  <w:r><w:t xml:space="preserve">dolor</w:t></w:r>
316
310
  </w:p>
317
311
  DOCX
318
312
  assert_equal normalize_wordml(expected_output), process(input)
319
- assert_equal [Sablon::Numbering::Definition.new(1001, 'ListNumber')], @numbering.definitions
320
313
  end
321
314
 
322
315
  def test_mixed_lists
@@ -327,7 +320,7 @@ class HTMLConverterTest < Sablon::TestCase
327
320
  <w:pStyle w:val="ListNumber" />
328
321
  <w:numPr>
329
322
  <w:ilvl w:val="0" />
330
- <w:numId w:val="1001" />
323
+ <w:numId w:val="1" />
331
324
  </w:numPr>
332
325
  </w:pPr>
333
326
  <w:r><w:t xml:space=\"preserve\">Lorem</w:t></w:r>
@@ -338,7 +331,7 @@ class HTMLConverterTest < Sablon::TestCase
338
331
  <w:pStyle w:val="ListBullet" />
339
332
  <w:numPr>
340
333
  <w:ilvl w:val="0" />
341
- <w:numId w:val="1002" />
334
+ <w:numId w:val="2" />
342
335
  </w:numPr>
343
336
  </w:pPr>
344
337
  <w:r><w:t xml:space="preserve">ipsum</w:t></w:r>
@@ -349,16 +342,13 @@ class HTMLConverterTest < Sablon::TestCase
349
342
  <w:pStyle w:val="ListNumber" />
350
343
  <w:numPr>
351
344
  <w:ilvl w:val="0" />
352
- <w:numId w:val="1003" />
345
+ <w:numId w:val="3" />
353
346
  </w:numPr>
354
347
  </w:pPr>
355
348
  <w:r><w:t xml:space="preserve">dolor</w:t></w:r>
356
349
  </w:p>
357
350
  DOCX
358
351
  assert_equal normalize_wordml(expected_output), process(input)
359
- assert_equal [Sablon::Numbering::Definition.new(1001, 'ListNumber'),
360
- Sablon::Numbering::Definition.new(1002, 'ListBullet'),
361
- Sablon::Numbering::Definition.new(1003, 'ListNumber')], @numbering.definitions
362
352
  end
363
353
 
364
354
  def test_nested_unordered_lists
@@ -369,7 +359,7 @@ class HTMLConverterTest < Sablon::TestCase
369
359
  <w:pStyle w:val="ListBullet" />
370
360
  <w:numPr>
371
361
  <w:ilvl w:val="0" />
372
- <w:numId w:val="1001" />
362
+ <w:numId w:val="1" />
373
363
  </w:numPr>
374
364
  </w:pPr>
375
365
  <w:r><w:t xml:space="preserve">Lorem</w:t></w:r>
@@ -380,7 +370,7 @@ class HTMLConverterTest < Sablon::TestCase
380
370
  <w:pStyle w:val="ListBullet" />
381
371
  <w:numPr>
382
372
  <w:ilvl w:val="1" />
383
- <w:numId w:val="1001" />
373
+ <w:numId w:val="1" />
384
374
  </w:numPr>
385
375
  </w:pPr>
386
376
  <w:r><w:t xml:space="preserve">ipsum</w:t></w:r>
@@ -391,38 +381,33 @@ class HTMLConverterTest < Sablon::TestCase
391
381
  <w:pStyle w:val="ListBullet" />
392
382
  <w:numPr>
393
383
  <w:ilvl w:val="2" />
394
- <w:numId w:val="1001" />
384
+ <w:numId w:val="1" />
395
385
  </w:numPr>
396
386
  </w:pPr>
397
387
  <w:r><w:t xml:space="preserve">dolor</w:t></w:r>
398
388
  </w:p>
399
389
  DOCX
400
390
  assert_equal normalize_wordml(expected_output), process(input)
401
- assert_equal [Sablon::Numbering::Definition.new(1001, 'ListBullet')], @numbering.definitions
402
391
  end
403
392
 
404
393
  def test_anchor_tag
405
- uid_generator = UIDTestGenerator.new
406
394
  input = '<p><a href="www.github.com">GitHub</a></p>'
407
- SecureRandom.stub(:uuid, uid_generator.method(:new_uid)) do |secure_random_instance|
408
- expected_output = <<-DOCX.strip
409
- <w:p>
410
- <w:pPr>
411
- <w:pStyle w:val="Paragraph" />
412
- </w:pPr>
413
- <w:hyperlink r:id="rId#{secure_random_instance.uuid}">
414
- <w:r>
415
- <w:rPr>
416
- <w:rStyle w:val="Hyperlink" />
417
- </w:rPr>
418
- <w:t xml:space="preserve">GitHub</w:t>
419
- </w:r>
420
- </w:hyperlink>
421
- </w:p>
422
- DOCX
423
- uid_generator.reset
424
- assert_equal normalize_wordml(expected_output), process(input)
425
- end
395
+ expected_output = <<-DOCX.strip
396
+ <w:p>
397
+ <w:pPr>
398
+ <w:pStyle w:val="Paragraph" />
399
+ </w:pPr>
400
+ <w:hyperlink r:id="rId#{@template.document.current_rid + 1}">
401
+ <w:r>
402
+ <w:rPr>
403
+ <w:rStyle w:val="Hyperlink" />
404
+ </w:rPr>
405
+ <w:t xml:space="preserve">GitHub</w:t>
406
+ </w:r>
407
+ </w:hyperlink>
408
+ </w:p>
409
+ DOCX
410
+ assert_equal normalize_wordml(expected_output), process(input)
426
411
  end
427
412
 
428
413
  def test_table_tag