3 # Copyright (c) 2005 Jonas Fonseca
6 test_description
='Test the DOM configuration module
8 This test checks that the normalization performed by the DOM configuration
14 test_normalize_output_equals
() {
20 URI
="test:$(normalize "$desc")"
22 sgml-parser
--src "$src" --normalize "$config" --uri "$URI" --src "$src" > output
23 echo "#document: $URI" > expected
24 echo "$out" |
sed -n '2,$p' |
sed 's/^/ /' >> expected
26 test_expect_success
"$desc" 'cmp output expected'
30 ## Config strings ###########################################################
32 NOOP
='cdata-sections,comments,element-content-whitespace,entities'
33 NOCOMMENTS
='cdata-sections,element-content-whitespace,entities'
34 CDATA2TEXT
='comments,element-content-whitespace,entities'
35 ENTITIES
='cdata-section,comments,element-content-whitespace'
36 NOWSTEXT
='cdata-section,comments,entities'
40 ## No-ops ###################################################################
42 test_normalize_output_equals \
43 'Normalization no-op.' \
45 '<roswell> <![CDATA[| that |]]><!-- ends --> well</roswell>' \
49 #cdata-section: | that |
53 test_normalize_output_equals \
56 'and<!-- comment:1 -->or<!-- comment:2 -->' \
63 test_normalize_output_equals \
64 'Keep CDATA sections ' \
66 '<![CDATA[and]]>or<![CDATA[maybe]]>' \
70 #cdata-section: maybe'
73 ## Comments #################################################################
75 test_normalize_output_equals \
76 'Remove comments. (I)' \
78 "<no><!-- comment -->?</no>" \
83 test_normalize_output_equals \
84 'Remove comments. (II)' \
86 '<!-- comment:1 -->and<!-- comment:2 -->' \
90 test_normalize_output_equals \
91 'Remove comments. (III)' \
93 'nothing to see <!-- comment -->here' \
95 #text: nothing to see here'
98 ## Entities #################################################################
100 # Entities should be shown 'verbatim' here after expansion.
102 test_normalize_output_equals \
103 'Expand entities. (I)' \
109 test_normalize_output_equals \
110 'Expand entities. (II)' \
112 '&bad-entity&good-entity;' \
114 #text: &bad-entity;&good-entity;'
116 test_normalize_output_equals \
117 'Expand entities. (III)' \
125 ## CDATA Sections ###########################################################
127 test_normalize_output_equals \
128 'Replace CDATA section with text. (I)' \
130 '<![CDATA[a small text snippet]]>' \
132 #text: a small text snippet'
134 test_normalize_output_equals \
135 'Replace CDATA section with text. (II)' \
137 '<![CDATA[a small]]> <![CDATA[text snippet]]>' \
139 #text: a small text snippet'
141 test_normalize_output_equals \
142 'Replace CDATA section with text. (III)' \
144 'before <![CDATA[and]]> after' \
146 #text: before and after'
149 ## Element Content Whitespace ###############################################
151 test_normalize_output_equals \
152 'Remove element content whitespace. (I)' \
162 # I haven't read the specs about this thing, for now it just blasts all
163 # space-only text nodes. Probably not the wanted behaviour all of the time.
165 test_normalize_output_equals \
166 'Remove element content whitespace. (II)' \
168 '<e>space between &this; &that; gets removed</e>' \
172 entity-reference: this
173 entity-reference: that
177 ## Mixes ####################################################################
179 test_normalize_output_equals \
180 'Normalization mix #1. (I)' \
182 'before <![CDATA[and]]> after &some;<!--comments--> remain' \
184 #text: before and after &some; remain'
186 test_normalize_output_equals \
187 'Normalization mix #1. (II)' \
189 '<!--a-->b&c; <![CDATA[d]]>' \
194 ## Special ELinks Extensions ################################################
196 test_normalize_output_equals \
197 'Remove unknown (HTML) elements and attributes. (I)' \
199 '<html wack="..."><title w00t="...">where?<doit>here!</doit></title></html>' \
205 test_normalize_output_equals \
206 'Remove unknown (HTML) elements and attributes. (II)' \
208 '<x y=""><z></z></x> aint no HTML' \
210 #text: aint no HTML' \
212 test_normalize_output_equals \
213 'Normalize whitespace. (I)' \
214 "$NOOP,normalize-whitespace" \
219 lot of useless space.' \
221 #text: Here is a lot of useless space.' \
223 test_normalize_output_equals \
224 'Normalize whitespace. (II)' \
225 "$CDATA2TEXT,normalize-whitespace" \
226 'Could we <![CDATA[ please ]]> read that again?' \
228 #text: Could we please read that again?' \