Debian Codegraph @

tests/parser/comments.txt

raw
1 # The parsoid-compatible option below is only relevant when we are running
2 # parser tests in integrated mode with Parsoid. This option is ignored
3 # when this test file is run with Parsoid in standalone mode.
4 !! options
5 parsoid-compatible=wt2html,wt2wt
6 version=2
7 !! end
8
9 !!article
10 Template:Foo
11 !!text
12 FOO
13 !!endarticle
14
15 !! article
16 Template:Blank
17 !! text
18 !! endarticle
19
20 !! test
21 Comments and Indent-Pre
22 !! wikitext
23 <!-- comment 1 --> asdf
24
25 <!-- comment 1 --> asdf
26 <!-- comment 2 -->
27
28 <!-- comment 1 --> asdf
29 <!-- comment 2 -->xyz
30
31 <!-- comment 1 --> asdf
32 <!-- comment 2 --> xyz
33 !! html
34 <pre>asdf
35 </pre>
36 <pre>asdf
37 </pre>
38 <pre>asdf
39 </pre>
40 <p>xyz
41 </p>
42 <pre>asdf
43 xyz
44 </pre>
45 !! end
46
47 !! test
48 Comment test 2a
49 !! wikitext
50 asdf
51 <!-- comment 1 -->
52 jkl
53 !! html
54 <p>asdf
55 jkl
56 </p>
57 !! end
58
59 !! test
60 Comment test 2b
61 !! wikitext
62 asdf
63 <!-- comment 1 -->
64
65 jkl
66 !! html
67 <p>asdf
68 </p><p>jkl
69 </p>
70 !! end
71
72 !! test
73 Comment test 3
74 !! wikitext
75 asdf
76 <!-- comment 1 -->
77 <!-- comment 2 -->
78 jkl
79 !! html
80 <p>asdf
81 jkl
82 </p>
83 !! end
84
85 !! test
86 Comment test 4
87 !! wikitext
88 asdf<!-- comment 1 -->jkl
89 !! html
90 <p>asdfjkl
91 </p>
92 !! end
93
94 !! test
95 Comment spacing
96 !! wikitext
97 a
98 <!-- foo --> b <!-- bar -->
99 c
100 !! html
101 <p>a
102 </p>
103 <pre> b
104 </pre>
105 <p>c
106 </p>
107 !! end
108
109 !! test
110 Comment whitespace
111 !! wikitext
112 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
113 !! html
114 !! end
115
116 !! test
117 Comment semantics and delimiters
118 !! wikitext
119 <!-- --><!----><!-----><!------>
120 !! html/php
121 !! html/parsoid
122 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
123 !! end
124
125 !! test
126 Comment semantics and delimiters, redux
127 !! wikitext
128 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
129 -- foo -- funky huh? ... -->
130 !! html/php
131 !! html/parsoid
132 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
133 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
134 !! end
135
136 !! test
137 Comment semantics and delimiters: directors cut
138 !! wikitext
139 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
140 everything starting with < followed by !-- until the first -- and > we see,
141 that wouldn't be valid XML however, since in XML -- has to terminate a comment
142 -->-->
143 !! html/php
144 <p>--&gt;
145 </p>
146 !! html/parsoid
147 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
148 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
149 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
150 --><p>--></p>
151 !! end
152
153 !! test
154 Comment semantics: nesting
155 !! wikitext
156 <!--<!-- no, we're not going to do anything fancy here -->-->
157 !! html/php
158 <p>--&gt;
159 </p>
160 !! html/parsoid
161 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
162 !! end
163
164 # Parsoid closes the unclosed comment, even if it means a slight
165 # round-trip diff.
166 !! test
167 Comment semantics: unclosed comment at end
168 !! options
169 parsoid=wt2html,html2html
170 !! wikitext
171 <!--This comment will run out to the end of the document
172 !! html/php
173 !! html/parsoid
174 <!--This comment will run out to the end of the document-->
175 !! end
176
177 !! test
178 Comment semantics: normalize comments to play nice with XML and browsers
179 !! wikitext
180 <!-- Browsers --!> think this is closed -->
181 <!--> This would normally be text -->
182 <!---> As would this -->
183 <!-- XML doesn't like trailing dashes -------->
184 <!-- Nor doubled hyphens -- anywhere in the data -->
185 But this is not a comment.
186 !! html/php
187 <p>But this is not a comment.
188 </p>
189 !! html/parsoid
190 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
191 <!--&#x3E; This would normally be text -->
192 <!--&#x2D;&#x3E; As would this -->
193 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
194 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
195 <p>But this is not a comment.</p>
196 !! end
197
198 !! test
199 Comment semantics: round-trip even text which contains encoded -->
200 !! wikitext
201 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
202 !! html/parsoid
203 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
204 !! end
205
206 !! test
207 Comment in template title
208 !! wikitext
209 {{f<!---->oo}}
210 !! html
211 <p>FOO
212 </p>
213 !! end
214
215 !! test
216 Comment on its own line post-expand
217 !! wikitext
218 a
219 {{blank}}<!---->
220 b
221 !! html
222 <p>a
223 </p><p>b
224 </p>
225 !! end
226
227 !! test
228 Comment on its own line post-expand with non-significant whitespace
229 !! wikitext
230 a
231 {{blank}} <!---->
232 b
233 !! html
234 <p>a
235 </p><p>b
236 </p>
237 !! end
238
239 !! test
240 Multiple comments should still parse as SOL-transparent
241 !! options
242 parsoid=wt2html,wt2wt
243 !! wikitext
244 <!--c1-->*a
245 <!--c2--><!--c3--><!--c4-->*b
246 !! html/php
247 <ul><li>a</li>
248 <li>b</li></ul>
249 !! html/parsoid
250 <!--c1--><ul>
251 <li>a
252 </li>
253 <!--c2--><!--c3--><!--c4-->
254 <li>b
255 </li>
256 </ul>
257 !! end
258
259 ## Make sure ">" gets escaped in comments to avoid XSS
260 !! test
261 IE conditional comments
262 !! wikitext
263 <!--[if lt IE 9]>
264 <script>alert('hi');</script>
265 <![endif]-->
266 !! html/parsoid
267 <!--[if lt IE 9]&#x3E;
268 <script&#x3E;alert('hi');</script&#x3E;
269 <![endif]-->
270 !! end
271
272 ## Regession test for Parsoid
273 !! test
274 Comment with valid json
275 !! wikitext
276 hi <!--{"hi":"ho"}--> ho
277 !! html/php
278 <p>hi ho
279 </p>
280 !! html/parsoid
281 <p>hi <!--{"hi":"ho"}--> ho</p>
282 !! end