| 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:1x |
| 11 |
!! text |
| 12 |
{{{1}}} |
| 13 |
!! endarticle |
| 14 |
|
| 15 |
!! test |
| 16 |
<pre> with attributes (T5202) |
| 17 |
!! wikitext |
| 18 |
<pre style="background: blue; color:white">Bluescreen of WikiDeath</pre> |
| 19 |
!! html |
| 20 |
<pre style="background: blue; color:white">Bluescreen of WikiDeath</pre> |
| 21 |
!! end |
| 22 |
|
| 23 |
!! test |
| 24 |
<pre> with width attribute (T5202) |
| 25 |
!! wikitext |
| 26 |
<pre width="8">Narrow screen goodies</pre> |
| 27 |
!! html |
| 28 |
<pre width="8">Narrow screen goodies</pre> |
| 29 |
!! end |
| 30 |
|
| 31 |
!! test |
| 32 |
<pre> with forbidden attribute (T5202) |
| 33 |
!! wikitext |
| 34 |
<pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre> |
| 35 |
!! html |
| 36 |
<pre width="8">Narrow screen goodies</pre> |
| 37 |
!! end |
| 38 |
|
| 39 |
!! test |
| 40 |
Entities inside <pre> |
| 41 |
!! wikitext |
| 42 |
<pre><</pre> |
| 43 |
!! html |
| 44 |
<pre><</pre> |
| 45 |
!! end |
| 46 |
|
| 47 |
!! test |
| 48 |
<pre> with forbidden attribute values (T5202) |
| 49 |
!! wikitext |
| 50 |
<pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre> |
| 51 |
!! html |
| 52 |
<pre width="8" style="/* insecure input */">Narrow screen goodies</pre> |
| 53 |
!! end |
| 54 |
|
| 55 |
!! test |
| 56 |
<nowiki> inside <pre> (T15238) |
| 57 |
!! wikitext |
| 58 |
<pre> |
| 59 |
<nowiki> |
| 60 |
</pre> |
| 61 |
<pre> |
| 62 |
<nowiki></nowiki> |
| 63 |
</pre> |
| 64 |
<pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre> |
| 65 |
!! html |
| 66 |
<pre><nowiki> |
| 67 |
</pre> |
| 68 |
<pre> |
| 69 |
|
| 70 |
</pre> |
| 71 |
<pre><nowiki>Foo</nowiki></pre> |
| 72 |
!! end |
| 73 |
|
| 74 |
!! test |
| 75 |
<nowiki> inside of #tag:pre |
| 76 |
!! wikitext |
| 77 |
{{#tag:pre|Foo <nowiki>→bar</nowiki>}} |
| 78 |
!! html/php |
| 79 |
<pre>Foo →bar</pre> |
| 80 |
!! html/parsoid+standalone |
| 81 |
<pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:pre","function":"tag"},"params":{"1":{"wt":"Foo <nowiki>&rarr;bar</nowiki>"}},"i":0}}]}'>Foo <span typeof="mw:Entity">→</span>bar</pre> |
| 82 |
!! html/parsoid+integrated |
| 83 |
<pre about="#mwt1" typeof="mw:Extension/pre mw:Transclusion" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"Foo <nowiki>&rarr;bar</nowiki>"},"parts":[{"template":{"target":{"wt":"#tag:pre","function":"tag"},"params":{"1":{"wt":"Foo <nowiki>&rarr;bar</nowiki>"}},"i":0}}]}'>Foo →bar</pre> |
| 84 |
!! end |
| 85 |
|
| 86 |
## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that |
| 87 |
## aren't enclosed in nowikis. |
| 88 |
!! test |
| 89 |
<nowiki> and <pre> preference (first one wins) |
| 90 |
!! options |
| 91 |
parsoid=wt2html |
| 92 |
!! wikitext |
| 93 |
<pre> |
| 94 |
<nowiki> |
| 95 |
</pre> |
| 96 |
</nowiki> |
| 97 |
</pre> |
| 98 |
|
| 99 |
<nowiki> |
| 100 |
<pre> |
| 101 |
<nowiki> |
| 102 |
</pre> |
| 103 |
</nowiki> |
| 104 |
</pre> |
| 105 |
|
| 106 |
!! html/php |
| 107 |
<pre><nowiki> |
| 108 |
</pre> |
| 109 |
<p></nowiki> |
| 110 |
</p> |
| 111 |
|
| 112 |
<p> |
| 113 |
<pre> |
| 114 |
<nowiki> |
| 115 |
</pre> |
| 116 |
|
| 117 |
</p> |
| 118 |
!! html/parsoid |
| 119 |
<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n<nowiki>\n"}}'><nowiki> |
| 120 |
</pre> |
| 121 |
<p></nowiki></p> |
| 122 |
|
| 123 |
|
| 124 |
<p><span typeof="mw:Nowiki"> |
| 125 |
<pre> |
| 126 |
<nowiki> |
| 127 |
</pre> |
| 128 |
</span></p> |
| 129 |
!! end |
| 130 |
|
| 131 |
!! test |
| 132 |
</pre> inside nowiki |
| 133 |
!! wikitext |
| 134 |
<nowiki></pre></nowiki> |
| 135 |
!! html |
| 136 |
<p></pre> |
| 137 |
</p> |
| 138 |
!! end |
| 139 |
|
| 140 |
!! test |
| 141 |
Empty pre; pre inside other HTML tags (T56946) |
| 142 |
!! wikitext |
| 143 |
a |
| 144 |
|
| 145 |
<div><pre> |
| 146 |
foo |
| 147 |
</pre></div> |
| 148 |
<pre></pre> |
| 149 |
!! html/php |
| 150 |
<p>a |
| 151 |
</p> |
| 152 |
<div><pre>foo |
| 153 |
</pre></div> |
| 154 |
<pre></pre> |
| 155 |
!! html/parsoid |
| 156 |
<p>a</p> |
| 157 |
|
| 158 |
<div data-parsoid='{"stx":"html"}'><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo |
| 159 |
</pre></div> |
| 160 |
<pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre> |
| 161 |
!! end |
| 162 |
|
| 163 |
!! test |
| 164 |
HTML pre followed by indent-pre |
| 165 |
!! wikitext |
| 166 |
<pre>foo</pre> |
| 167 |
bar |
| 168 |
!! html |
| 169 |
<pre>foo</pre> |
| 170 |
<pre>bar |
| 171 |
</pre> |
| 172 |
!! end |
| 173 |
|
| 174 |
!! test |
| 175 |
Block tag pre |
| 176 |
!! wikitext |
| 177 |
<p><pre>foo</pre></p> |
| 178 |
!! html/php |
| 179 |
<p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p> |
| 180 |
!! html/parsoid |
| 181 |
<p class='mw-empty-elt' data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre><p class='mw-empty-elt' data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p> |
| 182 |
!! end |
| 183 |
|
| 184 |
## Hmm, should Parsoid rt this? |
| 185 |
!! test |
| 186 |
Pres with newline attributes |
| 187 |
!! options |
| 188 |
parsoid=wt2html,html2html |
| 189 |
!! wikitext |
| 190 |
<pre class="one |
| 191 |
two">hi</pre> |
| 192 |
!! html/php |
| 193 |
<pre class="one two">hi</pre> |
| 194 |
!! html/parsoid |
| 195 |
<pre class="one two" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre> |
| 196 |
!! end |
| 197 |
|
| 198 |
!! test |
| 199 |
Things that look like <pre> tags aren't treated as such |
| 200 |
!! wikitext |
| 201 |
Barack Obama <President> of the United States |
| 202 |
<President></President> |
| 203 |
!! html |
| 204 |
<p>Barack Obama <President> of the United States |
| 205 |
<President></President> |
| 206 |
</p> |
| 207 |
!! end |
| 208 |
|
| 209 |
## Remex doesn't account for fostered content. |
| 210 |
## The difference between Parsoid and the PHP parser can be attributed to core |
| 211 |
## commit 674e8388cba and 710618f89af in Parsoid's repo. Parsoid doesn't |
| 212 |
## tokenize unmatched extension tags that shadow html tags as strings to ease |
| 213 |
## an escaping mechanism. See the comment in `maybeExtensionTag`. |
| 214 |
!! test |
| 215 |
Handle broken pre-like tags (T66025) |
| 216 |
!! options |
| 217 |
parsoid=wt2html |
| 218 |
!! wikitext |
| 219 |
{{1x|<pre <pre>x</pre>}} |
| 220 |
|
| 221 |
<table><pre </table> |
| 222 |
!! html/php |
| 223 |
<pre>x</pre> |
| 224 |
<pre <table></table> |
| 225 |
!! html/parsoid |
| 226 |
<pre typeof="mw:Extension/pre mw:Transclusion" about="#mwt2" data-parsoid='{"stx":"html","a":{"<pre":null},"sa":{"<pre":""},"pi":[[{"k":"1"}]]}' data-mw='{"name":"pre","attrs":{"<pre":""},"body":{"extsrc":"x"},"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"<pre <pre>x</pre>"}},"i":0}}]}'>x</pre> |
| 227 |
|
| 228 |
<pre data-parsoid='{"stx":"html","src":"<pre </table>","tagWidths":[13,0],"a":{"<":null,"table":null},"sa":{"<":"","table":""},"fostered":true,"autoInsertedEnd":true}'></pre><table data-parsoid='{"stx":"html","autoInsertedEnd":true}'></table> |
| 229 |
!! end |
| 230 |
|
| 231 |
## Similar to the above, but shows the difference between extension and html tags |
| 232 |
!! test |
| 233 |
Less than in attribute position |
| 234 |
!! wikitext |
| 235 |
<pre <pre>123</pre> |
| 236 |
|
| 237 |
<div <div>123</div> |
| 238 |
!! html/php |
| 239 |
<pre>123</pre><p> |
| 240 |
<div </p><div>123</div> |
| 241 |
!! html/parsoid |
| 242 |
<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"<pre":""},"body":{"extsrc":"123"}}'>123</pre><p> |
| 243 |
|
| 244 |
<div </p><div>123</div> |
| 245 |
!! end |
| 246 |
|
| 247 |
!! test |
| 248 |
Parsoid: handle pre with space after attribute |
| 249 |
!! options |
| 250 |
parsoid=wt2html |
| 251 |
!! wikitext |
| 252 |
<pre style="width:50%;" >{{1x|foo}}</pre> |
| 253 |
!! html/php |
| 254 |
<pre style="width:50%;">{{1x|foo}}</pre> |
| 255 |
!! html/parsoid |
| 256 |
<pre style="width:50%;" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"style":"width:50%;"},"body":{"extsrc":"{{1x|foo}}"}}'>{{1x|foo}}</pre> |
| 257 |
!! end |
| 258 |
|
| 259 |
!! test |
| 260 |
Self-closed pre |
| 261 |
!! wikitext |
| 262 |
<pre /> |
| 263 |
!! html/php |
| 264 |
<pre></pre> |
| 265 |
!! html/parsoid |
| 266 |
<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{}}'></pre> |
| 267 |
!! end |
| 268 |
|
| 269 |
### |
| 270 |
### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric) |
| 271 |
### |
| 272 |
|
| 273 |
!!test |
| 274 |
HTML-pre: 1. embedded newlines |
| 275 |
!! wikitext |
| 276 |
<pre>foo</pre> |
| 277 |
|
| 278 |
<pre> |
| 279 |
foo |
| 280 |
</pre> |
| 281 |
|
| 282 |
<pre> |
| 283 |
|
| 284 |
foo |
| 285 |
</pre> |
| 286 |
|
| 287 |
<pre> |
| 288 |
|
| 289 |
|
| 290 |
foo |
| 291 |
</pre> |
| 292 |
!! html/php |
| 293 |
<pre>foo</pre> |
| 294 |
<pre>foo |
| 295 |
</pre> |
| 296 |
<pre> |
| 297 |
|
| 298 |
foo |
| 299 |
</pre> |
| 300 |
<pre> |
| 301 |
|
| 302 |
|
| 303 |
foo |
| 304 |
</pre> |
| 305 |
!! html/parsoid |
| 306 |
<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre> |
| 307 |
|
| 308 |
<pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo |
| 309 |
</pre> |
| 310 |
|
| 311 |
<pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'> |
| 312 |
|
| 313 |
foo |
| 314 |
</pre> |
| 315 |
|
| 316 |
<pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'> |
| 317 |
|
| 318 |
|
| 319 |
foo |
| 320 |
</pre> |
| 321 |
!!end |
| 322 |
|
| 323 |
!! test |
| 324 |
HTML-pre: big spaces |
| 325 |
!! wikitext |
| 326 |
<pre> |
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
haha |
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
haha |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
</pre> |
| 342 |
!! html/php |
| 343 |
<pre> |
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
haha |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
haha |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
</pre> |
| 359 |
!! html/parsoid |
| 360 |
<pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\n\n\nhaha\n\n\n\n\nhaha\n\n\n\n\n"}}'> |
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
haha |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
haha |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
</pre> |
| 376 |
!! end |
| 377 |
|
| 378 |
!!test |
| 379 |
HTML-pre: 2: indented text |
| 380 |
!! wikitext |
| 381 |
<pre> |
| 382 |
foo |
| 383 |
</pre> |
| 384 |
!! html |
| 385 |
<pre> foo |
| 386 |
</pre> |
| 387 |
!!end |
| 388 |
|
| 389 |
!!test |
| 390 |
HTML-pre: 3: other wikitext |
| 391 |
!! wikitext |
| 392 |
<pre> |
| 393 |
* foo |
| 394 |
# bar |
| 395 |
= no-h = |
| 396 |
'' no-italic '' |
| 397 |
[[ NoLink ]] |
| 398 |
</pre> |
| 399 |
!! html/php |
| 400 |
<pre>* foo |
| 401 |
# bar |
| 402 |
= no-h = |
| 403 |
'' no-italic '' |
| 404 |
[[ NoLink ]] |
| 405 |
</pre> |
| 406 |
!! html/parsoid |
| 407 |
<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n* foo\n# bar\n= no-h =\n'' no-italic ''\n[[ NoLink ]]\n"}}'>* foo |
| 408 |
# bar |
| 409 |
= no-h = |
| 410 |
'' no-italic '' |
| 411 |
[[ NoLink ]] |
| 412 |
</pre> |
| 413 |
!!end |