pseudohikiparser 0.0.4 → 0.0.5.develop

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -311,6 +311,73 @@ TEXT
311
311
  assert_equal([[[["heading"]]]],parsed)
312
312
  end
313
313
 
314
+
315
+ def test_decorator
316
+ text = <<TEXT
317
+ //@class[section_name]
318
+ !!title of section
319
+
320
+ //@summary: Summary of the table
321
+ ||!header 1||! header 2
322
+ ||cell 1||cell 2
323
+
324
+ a paragraph.
325
+
326
+ //@class[class_name]
327
+ //@[id_name]
328
+ another paragraph.
329
+ TEXT
330
+
331
+ tree = PseudoHiki::BlockParser.parse(text.lines.to_a.map {|line| line.chomp })
332
+ assert_equal(PseudoHiki::BlockParser::BlockNode, tree.class)
333
+ assert_equal("section_name", tree[0].decorator["class"].id)
334
+ assert_equal(PseudoHiki::BlockParser::BlockElement::HeadingNode, tree[0].class)
335
+ assert_equal([[["title of section"]], [[[["header 1"]], [[" header 2"]]], [[["cell 1"]], [["cell 2"]]]], [[["a paragraph."]]], [[["another paragraph."]]]], tree[0])
336
+ assert_equal([["Summary of the table"]], tree[0][1].decorator["summary"].value)
337
+ assert_equal(PseudoHiki::BlockParser::BlockElement::TableNode, tree[0][1].class)
338
+ assert_equal(nil, tree[0][2].decorator)
339
+ assert_equal('id_name', tree[0][3].decorator[:id].id)
340
+ assert_equal('class_name', tree[0][3].decorator["class"].id)
341
+ end
342
+
343
+ def test_sectioning_node
344
+ text = <<TEXT
345
+ ! Main title
346
+
347
+ //@begin[header]
348
+ !! first title in header
349
+
350
+ paragraph
351
+
352
+ !! second title in header
353
+
354
+ paragraph2
355
+
356
+ //@end[header]
357
+
358
+ !! first subtitle in main part
359
+
360
+ paragraph3
361
+
362
+ TEXT
363
+
364
+ expected_tree = [[[[" Main title\n"]],
365
+ [
366
+ [[[" first title in header\n"]],
367
+ [[["paragraph\n"]]]],
368
+ [[[" second title in header\n"]],
369
+ [[["paragraph2\n"]]]]
370
+ ],
371
+ [[[" first subtitle in main part\n"]],
372
+ [[["paragraph3\n"]]]]]]
373
+
374
+
375
+ tree = PseudoHiki::BlockParser.parse(text)
376
+ assert_equal(expected_tree, tree)
377
+ assert_kind_of(PseudoHiki::BlockParser::BlockElement::SectioningNode, tree[0][1])
378
+ assert_equal("header", tree[0][1].node_id)
379
+ end
380
+
314
381
  def test_comment_out_followed_by_a_verbatim_block
315
382
  text = <<TEXT
316
383
  the first paragraph
@@ -0,0 +1,3 @@
1
+ h1 {
2
+ margin-left: 0.5em;
3
+ }
@@ -0,0 +1,200 @@
1
+ #/usr/bin/env ruby
2
+
3
+ require 'minitest/autorun'
4
+ require 'lib/htmlelement'
5
+ require 'lib/htmlelement/utils'
6
+ require 'pseudohikiparser'
7
+
8
+ class TC_HtmlElement_Utils_LinkManager < MiniTest::Unit::TestCase
9
+ def setup
10
+ @default_domain = "http://www.example.org/default_path"
11
+ @from_host_names = ["stage.example.org", "develop.example.org"]
12
+ @link_manager = HtmlElement::Utils::LinkManager.new(@default_domain,
13
+ @from_host_names)
14
+ @link_manager_without_scheme = HtmlElement::Utils::LinkManager.new("www.example.org/default_path",
15
+ @from_host_names)
16
+ @link_manager_without_from_host_names = HtmlElement::Utils::LinkManager.new("www.example.org/default_path")
17
+ end
18
+
19
+ def test_unify_host_names
20
+ assert_equal("http://www.example.org/path1",
21
+ @link_manager.unify_host_names("http://stage.example.org/path1"))
22
+ assert_equal("http://www.example.org/path1/path1-1",
23
+ @link_manager.unify_host_names("http://develop.example.org/path1/path1-1"))
24
+ end
25
+
26
+ def test_unify_host_names_without_scheme
27
+ assert_equal("http://www.example.org/path1",
28
+ @link_manager_without_scheme.unify_host_names("http://stage.example.org/path1"))
29
+ assert_equal("http://www.example.org/path1/path1-1",
30
+ @link_manager_without_scheme.unify_host_names("http://develop.example.org/path1/path1-1"))
31
+ end
32
+
33
+ def test_unify_host_names_without_from_host_names
34
+ assert_equal("http://stage.example.org/path1",
35
+ @link_manager_without_from_host_names.unify_host_names("http://stage.example.org/path1"))
36
+ assert_equal("http://develop.example.org/path1/path1-1",
37
+ @link_manager_without_from_host_names.unify_host_names("http://develop.example.org/path1/path1-1"))
38
+ end
39
+
40
+ def test_convert_to_relative_path
41
+ assert_equal("../path1", @link_manager.convert_to_relative_path("http://www.example.org/path1"))
42
+ assert_equal("../path1/path1-1/",
43
+ @link_manager.convert_to_relative_path("http://www.example.org/path1/path1-1/"))
44
+ assert_equal("./",
45
+ @link_manager.convert_to_relative_path(@default_domain + "/"))
46
+ assert_equal("./",
47
+ @link_manager.convert_to_relative_path(@default_domain))
48
+ end
49
+
50
+ def test_external_link?
51
+ assert(@link_manager.external_link?("http://www.example.com"), "In a different domain")
52
+ refute(@link_manager.external_link?("https://www.example.org/path2"), "In the same domain")
53
+ end
54
+
55
+ def test_collect_elements_by_name
56
+ hiki_text = <<TEXT
57
+ !! Sample data with links
58
+
59
+ *[[Default path|http://www.example.org/default_path/]]
60
+ *[[Default index|http://www.example.org/default_path/index.html]]
61
+ *[[Path for staging server|http://stage.example.org/path1/path1-1/index.html]]
62
+ TEXT
63
+
64
+ expected_html = <<HTML
65
+ <div class="section h2">
66
+ <h2> Sample data with links
67
+ </h2>
68
+ <ul>
69
+ <li><a href="./">Default path</a>
70
+ </li>
71
+ <li><a href="index.html">Default index</a>
72
+ </li>
73
+ <li><a href="../path1/path1-1/index.html">Path for staging server</a>
74
+ </li>
75
+ </ul>
76
+ <!-- end of section h2 -->
77
+ </div>
78
+ HTML
79
+
80
+ html_str = PseudoHiki::Format.to_xhtml(hiki_text) do |html|
81
+ links = HtmlElement::Utils.collect_elements_by_name(html, "a".freeze)
82
+ links.each do |a|
83
+ href = a["href"]
84
+ href = @link_manager.unify_host_names(href)
85
+ href = @link_manager.convert_to_relative_path(href)
86
+ a["href"] = href
87
+ end
88
+ end
89
+
90
+ assert_equal(expected_html, html_str)
91
+ end
92
+
93
+ def test_use_relative_path_for_in_domain_links
94
+ hiki_text = <<TEXT
95
+ !! Sample data with links
96
+
97
+ *[[Default path|http://www.example.org/default_path/]]
98
+ *[[Default index|http://www.example.org/default_path/index.html]]
99
+ *[[Path for staging server|http://stage.example.org/path1/path1-1/index.html]]
100
+ TEXT
101
+
102
+ expected_html = <<HTML
103
+ <div class="section h2">
104
+ <h2> Sample data with links
105
+ </h2>
106
+ <ul>
107
+ <li><a href="./">Default path</a>
108
+ </li>
109
+ <li><a href="index.html">Default index</a>
110
+ </li>
111
+ <li><a href="../path1/path1-1/index.html">Path for staging server</a>
112
+ </li>
113
+ </ul>
114
+ <!-- end of section h2 -->
115
+ </div>
116
+ HTML
117
+
118
+ html_str = PseudoHiki::Format.to_xhtml(hiki_text) do |html|
119
+ @link_manager.use_relative_path_for_in_domain_links(html).to_s
120
+ end
121
+
122
+ assert_equal(expected_html, html_str)
123
+ end
124
+ end
125
+
126
+ class TC_HtmlElement_Utils_TableManager < MiniTest::Unit::TestCase
127
+ def setup
128
+ table_with_row_header_text = <<TABLE
129
+ ||!header1||!header2||!header3
130
+ ||row1-1||row1-2||row1-3
131
+ ||row2-1||row2-2||row2-3
132
+ TABLE
133
+
134
+ table_with_col_header_text = <<TABLE
135
+ ||!header1||col1-1||col2-1
136
+ ||!header2||col1-2||col2-2
137
+ ||!header3||col1-3||col2-3
138
+ TABLE
139
+
140
+ table_with_row_header_and_caption_text = <<TABLE
141
+ //@caption: Caption
142
+ ||!header1||!header2||!header3
143
+ ||row1-1||row1-2||row1-3
144
+ ||row2-1||row2-2||row2-3
145
+ TABLE
146
+
147
+ @table_manager = HtmlElement::Utils::TableManager.new
148
+ @table_with_row_header = PseudoHiki::BlockParser.parse(table_with_row_header_text)
149
+ @table_with_col_header = PseudoHiki::BlockParser.parse(table_with_col_header_text)
150
+ @table_with_row_header_and_caption = PseudoHiki::BlockParser.parse(table_with_row_header_and_caption_text)
151
+
152
+ end
153
+
154
+ def test_guess_header_scope
155
+ html_table = PseudoHiki::HtmlFormat.format(@table_with_row_header)[0]
156
+ assert_equal("col", @table_manager.guess_header_scope(html_table))
157
+
158
+ html_table = PseudoHiki::HtmlFormat.format(@table_with_col_header)[0]
159
+ assert_equal("row", @table_manager.guess_header_scope(html_table))
160
+
161
+ html_table = PseudoHiki::HtmlFormat.format(@table_with_row_header_and_caption)[0]
162
+ assert_equal("col", @table_manager.guess_header_scope(html_table))
163
+ end
164
+
165
+ def test_assign_scope
166
+ col_scope_table = <<TABLE
167
+ <table>
168
+ <tr><th scope="col">header1</th><th scope="col">header2</th><th scope="col">header3
169
+ </th></tr>
170
+ <tr><td>row1-1</td><td>row1-2</td><td>row1-3
171
+ </td></tr>
172
+ <tr><td>row2-1</td><td>row2-2</td><td>row2-3
173
+ </td></tr>
174
+ </table>
175
+ TABLE
176
+
177
+ row_scope_table = <<TABLE
178
+ <table>
179
+ <tr><th scope="row">header1</th><td>col1-1</td><td>col2-1
180
+ </td></tr>
181
+ <tr><th scope="row">header2</th><td>col1-2</td><td>col2-2
182
+ </td></tr>
183
+ <tr><th scope="row">header3</th><td>col1-3</td><td>col2-3
184
+ </td></tr>
185
+ </table>
186
+ TABLE
187
+
188
+ html_table = PseudoHiki::HtmlFormat.format(@table_with_row_header)[0]
189
+ @table_manager.assign_scope(html_table)
190
+ assert_equal(col_scope_table, html_table.to_s)
191
+
192
+ html_table = PseudoHiki::HtmlFormat.format(@table_with_col_header)[0]
193
+ @table_manager.assign_scope(html_table)
194
+ assert_equal(row_scope_table, html_table.to_s)
195
+
196
+ html_table = PseudoHiki::HtmlFormat.format(@table_with_row_header)[0]
197
+ HtmlElement::Utils::TableManager.assign_scope(html_table)
198
+ assert_equal(col_scope_table, html_table.to_s)
199
+ end
200
+ end
@@ -122,6 +122,8 @@ a paragraph with a normal [[link|http://www.example.org/]]
122
122
  a paragraph with an [[image|http://www.example.org/image.png]]
123
123
 
124
124
  a paragraph with a link to an image from [[[[a thumbnail image|image/thumb_nail.png]]|http://www.example.org/image.png]]
125
+
126
+ an img element with an empty alt attribute: [[|http://www.example.org/image.png]]
125
127
  TEXT
126
128
 
127
129
  html = <<HTML
@@ -135,6 +137,10 @@ a paragraph with an <img alt="image" src="http://www.example.org/image.png">
135
137
  <p>
136
138
  a paragraph with a link to an image from <a href="http://www.example.org/image.png"><img alt="a thumbnail image" src="image/thumb_nail.png">
137
139
  </a>
140
+ </p>
141
+ <p>
142
+ an img element with an empty alt attribute: <img alt="" src="http://www.example.org/image.png">
143
+
138
144
  </p>
139
145
  HTML
140
146
 
@@ -769,6 +775,419 @@ HTML
769
775
  assert_equal(xhtml, HtmlFormat.format(tree, {:auto_link_in_verbatim => false }).to_s)
770
776
  end
771
777
 
778
+ def test_decorator
779
+ text = <<TEXT
780
+ //@class[section_type]
781
+ !!title of section
782
+
783
+ a paragraph.
784
+
785
+ //@class[class_name]
786
+ //@id[id_name]
787
+ another paragraph.
788
+ TEXT
789
+
790
+ xhtml = <<HTML
791
+ <div class="section_type">
792
+ <h2>title of section</h2>
793
+ <p>
794
+ a paragraph.</p>
795
+ <p class="class_name" id="ID_NAME">
796
+ another paragraph.</p>
797
+ <!-- end of section_type -->
798
+ </div>
799
+ HTML
800
+ tree = BlockParser.parse(text.lines.to_a.map {|line| line.chomp })
801
+ assert_equal(xhtml, XhtmlFormat.format(tree).to_s)
802
+ end
803
+
804
+ def test_decorator_for_table
805
+ text = <<TEXT
806
+ //@summary: Summary of the table
807
+ ||!header 1||! header 2
808
+ ||cell 1||cell 2
809
+ TEXT
810
+
811
+ xhtml = <<HTML
812
+ <table summary="Summary of the table">
813
+ <tr><th>header 1</th><th> header 2</th></tr>
814
+ <tr><td>cell 1</td><td>cell 2</td></tr>
815
+ </table>
816
+ HTML
817
+ tree = BlockParser.parse(text.lines.to_a.map {|line| line.chomp })
818
+ assert_equal(xhtml, XhtmlFormat.format(tree).to_s)
819
+ end
820
+
821
+ def test_decorator_for_table_summary
822
+ text = <<TEXT
823
+ //@summary: Summary of the table
824
+ ||!header 1||! header 2
825
+ TEXT
826
+
827
+ xhtml = <<HTML
828
+ <table summary="Summary of the table">
829
+ <tr><th>header 1</th><th> header 2
830
+ </th></tr>
831
+ </table>
832
+ HTML
833
+ tree = BlockParser.parse(text.lines.to_a.map {|line| line })
834
+ assert_equal(xhtml, XhtmlFormat.format(tree).to_s)
835
+ end
836
+
837
+ def test_decorator_for_table_caption
838
+ text = <<TEXT
839
+ //@caption: Caption of ''the table''
840
+ ||!header 1||! header 2
841
+ ||cell 1||cell 2
842
+ TEXT
843
+
844
+ xhtml = <<HTML
845
+ <table>
846
+ <caption>Caption of <em>the table</em></caption>
847
+ <tr><th>header 1</th><th> header 2</th></tr>
848
+ <tr><td>cell 1</td><td>cell 2</td></tr>
849
+ </table>
850
+ HTML
851
+ tree = BlockParser.parse(text.lines.to_a.map {|line| line.chomp })
852
+ assert_equal(xhtml, XhtmlFormat.format(tree).to_s)
853
+ end
854
+
855
+ def test_decorator_for_table_caption_with_tags
856
+ text = <<TEXT
857
+ //@caption: [[''Table caption''that begins with a link|http://www.example.org/]] and contains other strings
858
+ ||!header 1||! header 2
859
+ TEXT
860
+
861
+ xhtml = <<HTML
862
+ <table>
863
+ <caption><a href="http://www.example.org/"><em>Table caption</em>that begins with a link</a> and contains other strings</caption>
864
+ <tr><th>header 1</th><th> header 2</th></tr>
865
+ </table>
866
+ HTML
867
+ tree = BlockParser.parse(text.lines.to_a.map {|line| line.chomp })
868
+ assert_equal(xhtml, XhtmlFormat.format(tree).to_s)
869
+ end
870
+
871
+ def test_decorator_for_verbatim
872
+ text = <<TEXT
873
+ //@code[ruby]
874
+ def bonjour!
875
+ puts "Bonjour!"
876
+ end
877
+ TEXT
878
+
879
+ xhtml = <<HTML
880
+ <pre>
881
+ def bonjour!
882
+ puts &quot;Bonjour!&quot;
883
+ end
884
+ </pre>
885
+ HTML
886
+
887
+ tree = BlockParser.parse(text.lines.to_a)
888
+ assert_equal(xhtml, XhtmlFormat.format(tree).to_s)
889
+ end
890
+
891
+ def test_sectioning_node
892
+ text = <<TEXT
893
+ ! Main title
894
+
895
+ //@begin[header]
896
+ !! first title in header
897
+
898
+ paragraph
899
+
900
+ !! second title in header
901
+
902
+ paragraph2
903
+
904
+ //@end[header]
905
+
906
+ !! first subtitle in main part
907
+
908
+ paragraph3
909
+
910
+ //@begin[#footer]
911
+
912
+ paragraph4
913
+
914
+ //@end[#footer]
915
+
916
+ TEXT
917
+
918
+ expected_html = <<HTML
919
+ <div class="section h1">
920
+ <h1> Main title
921
+ </h1>
922
+ <div class="header">
923
+ <div class="section h2">
924
+ <h2> first title in header
925
+ </h2>
926
+ <p>
927
+ paragraph
928
+ </p>
929
+ <!-- end of section h2 -->
930
+ </div>
931
+ <div class="section h2">
932
+ <h2> second title in header
933
+ </h2>
934
+ <p>
935
+ paragraph2
936
+ </p>
937
+ <!-- end of section h2 -->
938
+ </div>
939
+ <!-- end of header -->
940
+ </div>
941
+ <div class="section h2">
942
+ <h2> first subtitle in main part
943
+ </h2>
944
+ <p>
945
+ paragraph3
946
+ </p>
947
+ <div class="section" id="footer">
948
+ <p>
949
+ paragraph4
950
+ </p>
951
+ <!-- end of footer -->
952
+ </div>
953
+ <!-- end of section h2 -->
954
+ </div>
955
+ <!-- end of section h1 -->
956
+ </div>
957
+ HTML
958
+
959
+ tree = BlockParser.parse(text.lines.to_a)
960
+ assert_equal(expected_html, XhtmlFormat.format(tree).to_s)
961
+ end
962
+
963
+ def test_sectioning_node_for_html5
964
+ text = <<TEXT
965
+ ! Main title
966
+
967
+ //@begin[header]
968
+ !! first title in header
969
+
970
+ paragraph
971
+
972
+ !! second title in header
973
+
974
+ paragraph2
975
+
976
+ //@end[header]
977
+
978
+ !! first subtitle in main part
979
+
980
+ paragraph3
981
+
982
+ //@begin[#footer]
983
+
984
+ paragraph4
985
+
986
+ //@end[#footer]
987
+
988
+ TEXT
989
+
990
+ expected_html = <<HTML
991
+ <section class="h1">
992
+ <h1> Main title
993
+ </h1>
994
+ <header>
995
+ <section class="h2">
996
+ <h2> first title in header
997
+ </h2>
998
+ <p>
999
+ paragraph
1000
+ </p>
1001
+ <!-- end of h2 -->
1002
+ </section>
1003
+ <section class="h2">
1004
+ <h2> second title in header
1005
+ </h2>
1006
+ <p>
1007
+ paragraph2
1008
+ </p>
1009
+ <!-- end of h2 -->
1010
+ </section>
1011
+ </header>
1012
+ <section class="h2">
1013
+ <h2> first subtitle in main part
1014
+ </h2>
1015
+ <p>
1016
+ paragraph3
1017
+ </p>
1018
+ <section id="footer">
1019
+ <p>
1020
+ paragraph4
1021
+ </p>
1022
+ <!-- end of footer -->
1023
+ </section>
1024
+ <!-- end of h2 -->
1025
+ </section>
1026
+ <!-- end of h1 -->
1027
+ </section>
1028
+ HTML
1029
+
1030
+ tree = BlockParser.parse(text.lines.to_a)
1031
+ assert_equal(expected_html, Xhtml5Format.format(tree).to_s)
1032
+ end
1033
+
1034
+ def test_sectioning_node_when_end_tag_is_omitted
1035
+ text = <<TEXT
1036
+ !! First part
1037
+
1038
+ paragraph1
1039
+
1040
+ //@begin[first_sub_part]
1041
+ !!! first title in first sub-part
1042
+
1043
+ paragraph2
1044
+
1045
+ !!! second title in first sub-part
1046
+
1047
+ paragraph3
1048
+
1049
+ //you should put //@end[first_sub_part] here.
1050
+
1051
+ !! Second part
1052
+
1053
+ paragraph4
1054
+
1055
+ //@begin[#footer]
1056
+
1057
+ paragraph5
1058
+
1059
+ //@end[#footer]
1060
+
1061
+ TEXT
1062
+
1063
+ expected_html = <<HTML
1064
+ <div class=\"section h2\">
1065
+ <h2> First part
1066
+ </h2>
1067
+ <p>
1068
+ paragraph1
1069
+ </p>
1070
+ <div class=\"section first_sub_part\">
1071
+ <div class=\"section h3\">
1072
+ <h3> first title in first sub-part
1073
+ </h3>
1074
+ <p>
1075
+ paragraph2
1076
+ </p>
1077
+ <!-- end of section h3 -->
1078
+ </div>
1079
+ <div class=\"section h3\">
1080
+ <h3> second title in first sub-part
1081
+ </h3>
1082
+ <p>
1083
+ paragraph3
1084
+ </p>
1085
+ <!-- end of section h3 -->
1086
+ </div>
1087
+ <!-- end of section first_sub_part -->
1088
+ </div>
1089
+ <!-- end of section h2 -->
1090
+ </div>
1091
+ <div class=\"section h2\">
1092
+ <h2> Second part
1093
+ </h2>
1094
+ <p>
1095
+ paragraph4
1096
+ </p>
1097
+ <div class=\"section\" id=\"footer\">
1098
+ <p>
1099
+ paragraph5
1100
+ </p>
1101
+ <!-- end of footer -->
1102
+ </div>
1103
+ <!-- end of section h2 -->
1104
+ </div>
1105
+ HTML
1106
+
1107
+ tree = BlockParser.parse(text.lines.to_a)
1108
+ assert_equal(expected_html, XhtmlFormat.format(tree).to_s)
1109
+ end
1110
+
1111
+ def test_sectioning_node_when_end_tag_is_wrongly_placed
1112
+ text = <<TEXT
1113
+ !! First part
1114
+
1115
+ paragraph1
1116
+
1117
+ //@begin[first_sub_part]
1118
+ !!! first title in first sub-part
1119
+
1120
+ paragraph2
1121
+
1122
+ !!! second title in first sub-part
1123
+
1124
+ paragraph3
1125
+
1126
+ //you should put //@end[first_sub_part] here.
1127
+
1128
+ !! Second part
1129
+
1130
+ paragraph4
1131
+
1132
+
1133
+ //@end[first_sub_part] this end tag is wrongly placed.
1134
+
1135
+ //@begin[#footer]
1136
+
1137
+ paragraph5
1138
+
1139
+ //@end[#footer]
1140
+
1141
+ TEXT
1142
+
1143
+ expected_html = <<HTML
1144
+ <div class=\"section h2\">
1145
+ <h2> First part
1146
+ </h2>
1147
+ <p>
1148
+ paragraph1
1149
+ </p>
1150
+ <div class=\"section first_sub_part\">
1151
+ <div class=\"section h3\">
1152
+ <h3> first title in first sub-part
1153
+ </h3>
1154
+ <p>
1155
+ paragraph2
1156
+ </p>
1157
+ <!-- end of section h3 -->
1158
+ </div>
1159
+ <div class=\"section h3\">
1160
+ <h3> second title in first sub-part
1161
+ </h3>
1162
+ <p>
1163
+ paragraph3
1164
+ </p>
1165
+ <!-- end of section h3 -->
1166
+ </div>
1167
+ <!-- end of section first_sub_part -->
1168
+ </div>
1169
+ <!-- end of section h2 -->
1170
+ </div>
1171
+ <div class=\"section h2\">
1172
+ <h2> Second part
1173
+ </h2>
1174
+ <p>
1175
+ paragraph4
1176
+ </p>
1177
+ <div class=\"section\" id=\"footer\">
1178
+ <p>
1179
+ paragraph5
1180
+ </p>
1181
+ <!-- end of footer -->
1182
+ </div>
1183
+ <!-- end of section h2 -->
1184
+ </div>
1185
+ HTML
1186
+
1187
+ tree = BlockParser.parse(text.lines.to_a)
1188
+ assert_equal(expected_html, XhtmlFormat.format(tree).to_s)
1189
+ end
1190
+
772
1191
  def test_comment_out_followed_by_a_verbatim_block
773
1192
  text = <<TEXT
774
1193
  the first paragraph