| 1 | # Copyright (C) 2005 ILOG http://www.ilog.fr |
|---|
| 2 | # and Foswiki Contributors. All Rights Reserved. Foswiki Contributors |
|---|
| 3 | # are listed in the AUTHORS file in the root of this distribution. |
|---|
| 4 | # NOTE: Please extend that file, not this notice. |
|---|
| 5 | # |
|---|
| 6 | # This program is free software; you can redistribute it and/or |
|---|
| 7 | # modify it under the terms of the GNU General Public License |
|---|
| 8 | # as published by the Free Software Foundation; either version 2 |
|---|
| 9 | # of the License, or (at your option) any later version. For |
|---|
| 10 | # more details read LICENSE in the root of the Foswiki distribution. |
|---|
| 11 | # |
|---|
| 12 | # This program is distributed in the hope that it will be useful, |
|---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 15 | # |
|---|
| 16 | # As per the GPL, removal of this notice is prohibited. |
|---|
| 17 | |
|---|
| 18 | # tests for the two translators, TML to HTML and HTML to TML, that |
|---|
| 19 | # support editing using WYSIWYG HTML editors. The tests are designed |
|---|
| 20 | # so that the round trip can be verified in as many cases as possible. |
|---|
| 21 | # Readers are invited to add more testcases. |
|---|
| 22 | # |
|---|
| 23 | # The tests require FOSWIKI_LIBS to include a pointer to the lib |
|---|
| 24 | # directory of a Foswiki installation, so it can pick up the bits |
|---|
| 25 | # of Foswiki it needs to include. |
|---|
| 26 | # |
|---|
| 27 | package TranslatorTests; |
|---|
| 28 | use base qw(FoswikiTestCase); |
|---|
| 29 | |
|---|
| 30 | use strict; |
|---|
| 31 | |
|---|
| 32 | require Foswiki::Plugins::WysiwygPlugin; |
|---|
| 33 | require Foswiki::Plugins::WysiwygPlugin::TML2HTML; |
|---|
| 34 | require Foswiki::Plugins::WysiwygPlugin::HTML2TML; |
|---|
| 35 | |
|---|
| 36 | # Bits for test type |
|---|
| 37 | # Fields in test records: |
|---|
| 38 | my $TML2HTML = 1 << 0; # test tml => html |
|---|
| 39 | my $HTML2TML = 1 << 1; # test html => finaltml (default tml) |
|---|
| 40 | my $ROUNDTRIP = 1 << 2; # test tml => => finaltml |
|---|
| 41 | |
|---|
| 42 | # Bit mask for selected test types |
|---|
| 43 | my $mask = $TML2HTML | $HTML2TML | $ROUNDTRIP; |
|---|
| 44 | |
|---|
| 45 | my $protecton = '<span class="WYSIWYG_PROTECTED">'; |
|---|
| 46 | my $linkon = '<span class="WYSIWYG_LINK">'; |
|---|
| 47 | my $protectoff = '</span>'; |
|---|
| 48 | my $linkoff = '</span>'; |
|---|
| 49 | my $preoff = '</span>'; |
|---|
| 50 | my $nop = "$protecton<nop>$protectoff"; |
|---|
| 51 | |
|---|
| 52 | # The following big table contains all the testcases. These are |
|---|
| 53 | # used to add a bunch of functions to the symbol table of this |
|---|
| 54 | # testcase, so they get picked up and run by TestRunner. |
|---|
| 55 | |
|---|
| 56 | # Each testcase is a subhash with fields as follows: |
|---|
| 57 | # exec => 1 to test TML -> HTML, 2 to test HTML -> TML, 3 to |
|---|
| 58 | # test both, anything else to skin the test. |
|---|
| 59 | # name => identifier (used to compose the testcase function name) |
|---|
| 60 | # tml => source topic meta-language |
|---|
| 61 | # html => expected html from expanding tml |
|---|
| 62 | # finaltml => optional expected tml from translating html. If not there, |
|---|
| 63 | # will use tml. Only use where round-trip can't be closed because |
|---|
| 64 | # we are testing deprecated syntax. |
|---|
| 65 | my $data = [ |
|---|
| 66 | { |
|---|
| 67 | exec => $TML2HTML | $HTML2TML, |
|---|
| 68 | name => 'Pling', |
|---|
| 69 | tml => 'Move !ItTest/site/ToWeb5 leaving web5 as !MySQL host', |
|---|
| 70 | html => <<HERE, |
|---|
| 71 | <p> |
|---|
| 72 | Move !<span class="WYSIWYG_LINK">ItTest</span>/site/ToWeb5 leaving web5 as !<span class="WYSIWYG_LINK">MySQL</span> host |
|---|
| 73 | </p> |
|---|
| 74 | HERE |
|---|
| 75 | finaltml => <<'HERE', |
|---|
| 76 | Move !ItTest/site/ToWeb5 leaving web5 as !MySQL host |
|---|
| 77 | HERE |
|---|
| 78 | }, |
|---|
| 79 | { |
|---|
| 80 | exec => $ROUNDTRIP, |
|---|
| 81 | name => 'linkAtStart', |
|---|
| 82 | tml => 'LinkAtStart', |
|---|
| 83 | html => $linkon . 'LinkAtStart' . $linkoff, |
|---|
| 84 | }, |
|---|
| 85 | { |
|---|
| 86 | exec => $ROUNDTRIP, |
|---|
| 87 | name => 'otherWebLinkAtStart', |
|---|
| 88 | tml => 'OtherWeb.LinkAtStart', |
|---|
| 89 | html => $linkon . 'OtherWeb.LinkAtStart' . $linkoff, |
|---|
| 90 | }, |
|---|
| 91 | { |
|---|
| 92 | exec => $ROUNDTRIP, |
|---|
| 93 | name => 'currentWebLinkAtStart', |
|---|
| 94 | tml => 'Current.LinkAtStart', |
|---|
| 95 | html => $linkon . 'Current.LinkAtStart' . $linkoff, |
|---|
| 96 | finaltml => 'Current.LinkAtStart', |
|---|
| 97 | }, |
|---|
| 98 | { |
|---|
| 99 | exec => $ROUNDTRIP, |
|---|
| 100 | name => 'simpleParas', |
|---|
| 101 | html => '1st paragraph<p />2nd paragraph', |
|---|
| 102 | tml => <<'HERE', |
|---|
| 103 | 1st paragraph |
|---|
| 104 | |
|---|
| 105 | 2nd paragraph |
|---|
| 106 | HERE |
|---|
| 107 | }, |
|---|
| 108 | { |
|---|
| 109 | exec => $ROUNDTRIP, |
|---|
| 110 | name => 'headings', |
|---|
| 111 | html => <<'HERE', |
|---|
| 112 | <h2 class="TML"> Sushi</h2><h3 class="TML"> Maguro</h3> |
|---|
| 113 | HERE |
|---|
| 114 | tml => <<'HERE', |
|---|
| 115 | ---++ Sushi |
|---|
| 116 | ---+++ Maguro |
|---|
| 117 | HERE |
|---|
| 118 | }, |
|---|
| 119 | { |
|---|
| 120 | exec => $ROUNDTRIP, |
|---|
| 121 | name => 'simpleStrong', |
|---|
| 122 | html => '<b>Bold</b>', |
|---|
| 123 | tml => '*Bold* |
|---|
| 124 | ' |
|---|
| 125 | }, |
|---|
| 126 | { |
|---|
| 127 | exec => $ROUNDTRIP, |
|---|
| 128 | name => 'strongLink', |
|---|
| 129 | html => <<HERE, |
|---|
| 130 | <b>reminded about${linkon}http://www.koders.com${linkoff}</b> |
|---|
| 131 | HERE |
|---|
| 132 | tml => '*reminded about http://www.koders.com*', |
|---|
| 133 | finaltml => '*reminded about http://www.koders.com*', |
|---|
| 134 | }, |
|---|
| 135 | { |
|---|
| 136 | exec => $ROUNDTRIP, |
|---|
| 137 | name => 'simpleItalic', |
|---|
| 138 | html => '<i>Italic</i>', |
|---|
| 139 | tml => '_Italic_', |
|---|
| 140 | }, |
|---|
| 141 | { |
|---|
| 142 | exec => $ROUNDTRIP, |
|---|
| 143 | name => 'boldItalic', |
|---|
| 144 | html => '<b><i>Bold italic</i></b>', |
|---|
| 145 | tml => '__Bold italic__', |
|---|
| 146 | }, |
|---|
| 147 | { |
|---|
| 148 | exec => $ROUNDTRIP, |
|---|
| 149 | name => 'simpleCode', |
|---|
| 150 | html => '<code>Code</code>', |
|---|
| 151 | tml => '=Code=' |
|---|
| 152 | }, |
|---|
| 153 | { |
|---|
| 154 | exec => $ROUNDTRIP, |
|---|
| 155 | name => 'strongCode', |
|---|
| 156 | html => '<b><code>Bold Code</code></b>', |
|---|
| 157 | tml => '==Bold Code==' |
|---|
| 158 | }, |
|---|
| 159 | { |
|---|
| 160 | exec => $ROUNDTRIP, |
|---|
| 161 | name => 'mixtureOfFormats', |
|---|
| 162 | html => <<'HERE', |
|---|
| 163 | <p><i>this</i><i>should</i><i>italicise</i><i>each</i><i>word</i><p /><b>and</b><b>this</b><b>should</b><b>embolden</b><b>each</b><b>word</b></p><p><i>mixing</i><b>them</b><i>should</i><b>work</b></p> |
|---|
| 164 | HERE |
|---|
| 165 | tml => <<'HERE', |
|---|
| 166 | _this_ _should_ _italicise_ _each_ _word_ |
|---|
| 167 | |
|---|
| 168 | *and* *this* *should* *embolden* *each* *word* |
|---|
| 169 | |
|---|
| 170 | _mixing_ *them* _should_ *work* |
|---|
| 171 | HERE |
|---|
| 172 | }, |
|---|
| 173 | { |
|---|
| 174 | exec => $ROUNDTRIP, |
|---|
| 175 | name => 'simpleVerbatim', |
|---|
| 176 | html => <<'HERE', |
|---|
| 177 | <span class="TMLverbatim"><br /><verbatim><br />Description<br /></verbatim><br /><br /><br />class CatAnimal {<br /> void purr() {<br /> code <here><br /> }<br />}<br /></span> |
|---|
| 178 | HERE |
|---|
| 179 | tml => <<'HERE', |
|---|
| 180 | <verbatim> |
|---|
| 181 | <verbatim> |
|---|
| 182 | Description |
|---|
| 183 | </verbatim> |
|---|
| 184 | |
|---|
| 185 | |
|---|
| 186 | class CatAnimal { |
|---|
| 187 | void purr() { |
|---|
| 188 | code <here> |
|---|
| 189 | } |
|---|
| 190 | } |
|---|
| 191 | </verbatim> |
|---|
| 192 | HERE |
|---|
| 193 | }, |
|---|
| 194 | { |
|---|
| 195 | exec => $HTML2TML, |
|---|
| 196 | name => 'spanVerbatim', |
|---|
| 197 | html => <<'HERE', |
|---|
| 198 | <span class="TMLverbatim"> |
|---|
| 199 | Oh....<br /> my....<br /> gaaaaaawd! |
|---|
| 200 | </span> |
|---|
| 201 | HERE |
|---|
| 202 | tml => <<'HERE', |
|---|
| 203 | <verbatim> |
|---|
| 204 | Oh.... |
|---|
| 205 | my.... |
|---|
| 206 | gaaaaaawd! |
|---|
| 207 | </verbatim> |
|---|
| 208 | HERE |
|---|
| 209 | }, |
|---|
| 210 | { |
|---|
| 211 | exec => $HTML2TML, |
|---|
| 212 | name => 'pVerbatim', |
|---|
| 213 | html => <<'HERE', |
|---|
| 214 | <p class="TMLverbatim"> |
|---|
| 215 | Oh....<br /> my....<br /> gaaaaaawd! |
|---|
| 216 | </p> |
|---|
| 217 | HERE |
|---|
| 218 | tml => <<'HERE', |
|---|
| 219 | <verbatim> |
|---|
| 220 | Oh.... |
|---|
| 221 | my.... |
|---|
| 222 | gaaaaaawd! |
|---|
| 223 | </verbatim> |
|---|
| 224 | HERE |
|---|
| 225 | }, |
|---|
| 226 | { |
|---|
| 227 | exec => $HTML2TML, |
|---|
| 228 | name => 'Item5165', |
|---|
| 229 | html => |
|---|
| 230 | '<pre class="TMLverbatim"><br />Before &nbsp; After<br /></pre>', |
|---|
| 231 | tml => '<verbatim> |
|---|
| 232 | Before After |
|---|
| 233 | </verbatim>', |
|---|
| 234 | }, |
|---|
| 235 | { |
|---|
| 236 | exec => $ROUNDTRIP, |
|---|
| 237 | name => 'simpleHR', |
|---|
| 238 | html => '<hr class="TMLhr"/><hr class="TMLhr"/>--', |
|---|
| 239 | tml => <<'HERE', |
|---|
| 240 | --- |
|---|
| 241 | ------- |
|---|
| 242 | -- |
|---|
| 243 | |
|---|
| 244 | HERE |
|---|
| 245 | finaltml => <<'HERE', |
|---|
| 246 | --- |
|---|
| 247 | --- |
|---|
| 248 | -- |
|---|
| 249 | HERE |
|---|
| 250 | }, |
|---|
| 251 | { |
|---|
| 252 | exec => $ROUNDTRIP, |
|---|
| 253 | name => 'simpleBullList', |
|---|
| 254 | html => 'Before<ul><li>bullet item</li></ul>After', |
|---|
| 255 | tml => <<'HERE', |
|---|
| 256 | Before |
|---|
| 257 | * bullet item |
|---|
| 258 | After |
|---|
| 259 | HERE |
|---|
| 260 | }, |
|---|
| 261 | { |
|---|
| 262 | exec => $ROUNDTRIP, |
|---|
| 263 | name => 'multiLevelBullList', |
|---|
| 264 | html => <<'HERE', |
|---|
| 265 | X |
|---|
| 266 | <ul><li>level 1 |
|---|
| 267 | <ul><li>level 2</li></ul></li></ul> |
|---|
| 268 | HERE |
|---|
| 269 | tml => <<'HERE', |
|---|
| 270 | X |
|---|
| 271 | * level 1 |
|---|
| 272 | * level 2 |
|---|
| 273 | |
|---|
| 274 | HERE |
|---|
| 275 | finaltml => <<'HERE', |
|---|
| 276 | X |
|---|
| 277 | * level 1 |
|---|
| 278 | * level 2 |
|---|
| 279 | HERE |
|---|
| 280 | }, |
|---|
| 281 | { |
|---|
| 282 | exec => $ROUNDTRIP, |
|---|
| 283 | name => 'orderedList', |
|---|
| 284 | html => <<'HERE', |
|---|
| 285 | <ol><li>Sushi</li></ol><p /><ol> |
|---|
| 286 | <li type="A">Sushi</li></ol><p /> |
|---|
| 287 | <ol><li type="i">Sushi</li></ol><p /> |
|---|
| 288 | <ol><li>Sushi</li><li type="A">Sushi</li><li type="i">Sushi</li></ol> |
|---|
| 289 | HERE |
|---|
| 290 | tml => <<'HERE', |
|---|
| 291 | 1 Sushi |
|---|
| 292 | |
|---|
| 293 | A. Sushi |
|---|
| 294 | |
|---|
| 295 | i. Sushi |
|---|
| 296 | |
|---|
| 297 | 1 Sushi |
|---|
| 298 | A. Sushi |
|---|
| 299 | i. Sushi |
|---|
| 300 | HERE |
|---|
| 301 | }, |
|---|
| 302 | { |
|---|
| 303 | exec => $ROUNDTRIP, |
|---|
| 304 | name => 'mixedList', |
|---|
| 305 | html => <<"HERE", |
|---|
| 306 | <ol><li>Things</li><li>Stuff |
|---|
| 307 | <ul><li>Banana Stuff</li><li>Other</li><li></li></ul></li><li>Something</li><li>kello$protecton<br />${protectoff}hitty</li></ol> |
|---|
| 308 | HERE |
|---|
| 309 | tml => <<'HERE', |
|---|
| 310 | 1 Things |
|---|
| 311 | 1 Stuff |
|---|
| 312 | * Banana Stuff |
|---|
| 313 | * Other |
|---|
| 314 | * |
|---|
| 315 | 1 Something |
|---|
| 316 | 1 kello<br />hitty |
|---|
| 317 | HERE |
|---|
| 318 | }, |
|---|
| 319 | { |
|---|
| 320 | exec => $ROUNDTRIP, |
|---|
| 321 | name => 'definitionList', |
|---|
| 322 | html => <<'HERE', |
|---|
| 323 | <dl> <dt> Sushi |
|---|
| 324 | </dt><dd>Japan</dd><dt>Dim Sum</dt><dd>S. F.</dd><dt>Sauerkraut</dt><dd>Germany</dd></dl> |
|---|
| 325 | <ul><li>Fennel</li></ul> |
|---|
| 326 | HERE |
|---|
| 327 | tml => <<'HERE', |
|---|
| 328 | $ Sushi: Japan |
|---|
| 329 | $ Dim Sum: S. F. |
|---|
| 330 | Sauerkraut: Germany |
|---|
| 331 | * Fennel |
|---|
| 332 | HERE |
|---|
| 333 | finaltml => <<'HERE', |
|---|
| 334 | $ Sushi: Japan |
|---|
| 335 | $ Dim Sum: S. F. |
|---|
| 336 | $ Sauerkraut: Germany |
|---|
| 337 | * Fennel |
|---|
| 338 | HERE |
|---|
| 339 | }, |
|---|
| 340 | { |
|---|
| 341 | exec => $ROUNDTRIP, |
|---|
| 342 | name => 'simpleTable', |
|---|
| 343 | html => <<'HERE', |
|---|
| 344 | Before |
|---|
| 345 | <table border="1" cellpadding="0" cellspacing="1"><tr><td><b>L</b></td><td><b>C</b></td><td><b>R</b></td></tr><tr><td> A2</td><td style="text-align: center" class="align-center"> 2</td><td style="text-align: right" class="align-right"> 2</td></tr><tr><td> A3</td><td style="text-align: center" class="align-center"> 3</td><td style="text-align: left" class="align-left"> 3</td></tr><tr><td> A4-6</td><td> four</td><td> four</td></tr><tr><td>^</td><td> five</td><td> five</td></tr></table><p /><table border="1" cellpadding="0" cellspacing="1"><tr><td>^</td><td> six</td><td> six</td></tr></table> |
|---|
| 346 | After |
|---|
| 347 | HERE |
|---|
| 348 | tml => <<'HERE', |
|---|
| 349 | Before |
|---|
| 350 | | *L* | *C* | *R* | |
|---|
| 351 | | A2 | 2 | 2 | |
|---|
| 352 | | A3 | 3 | 3 | |
|---|
| 353 | | A4-6 | four | four | |
|---|
| 354 | |^| five | five | |
|---|
| 355 | |
|---|
| 356 | |^| six | six | |
|---|
| 357 | After |
|---|
| 358 | |
|---|
| 359 | HERE |
|---|
| 360 | finaltml => <<'HERE', |
|---|
| 361 | Before |
|---|
| 362 | | *L* | *C* | *R* | |
|---|
| 363 | | A2 | 2 | 2 | |
|---|
| 364 | | A3 | 3 | 3 | |
|---|
| 365 | | A4-6 | four | four | |
|---|
| 366 | | ^ | five | five | |
|---|
| 367 | |
|---|
| 368 | | ^ | six | six | |
|---|
| 369 | After |
|---|
| 370 | HERE |
|---|
| 371 | }, |
|---|
| 372 | { |
|---|
| 373 | exec => 0, # disabled because of Kupu problems handling colspans |
|---|
| 374 | name => 'tableWithSpans', |
|---|
| 375 | html => <<'HERE', |
|---|
| 376 | <table border="1" cellpadding="0" cellspacing="1"><tr><td><b> L </b></td><td><b> C </b></td><td><b> R </b></td></tr><tr><td> A2 </td><td class="align-center" style="text-align: center"> 2 </td><td class="align-right" style="text-align: right"> 2 </td></tr><tr><td> A3 </td><td class="align-center" style="text-align: center"> 3 </td><td class="align-left" style="text-align: left"> 3 </td></tr><tr><td colspan="3"> multi span </td></tr><tr><td> A4-6 </td><td> four </td><td> four </td></tr><tr><td>^</td><td> five</td><td>five </td></tr></table><p /><table border="1" cellpadding="0" cellspacing="1"><tr><td>^</td><td>six</td><td>six</td></tr></table> |
|---|
| 377 | HERE |
|---|
| 378 | tml => <<'HERE', |
|---|
| 379 | |
|---|
| 380 | | *L* | *C* | *R* | |
|---|
| 381 | | A2 | 2 | 2 | |
|---|
| 382 | | A3 | 3 | 3 | |
|---|
| 383 | | multi span ||| |
|---|
| 384 | | A4-6 | four | four | |
|---|
| 385 | |^| five|five | |
|---|
| 386 | |
|---|
| 387 | |^| six | six | |
|---|
| 388 | |
|---|
| 389 | HERE |
|---|
| 390 | finaltml => <<'HERE', |
|---|
| 391 | |
|---|
| 392 | | *L* |*C* |*R* | |
|---|
| 393 | | A2 | 2 | 2 | |
|---|
| 394 | | A3 | 3 | 3 | |
|---|
| 395 | | multi span ||| |
|---|
| 396 | | A4-6 | four | four | |
|---|
| 397 | |^| five|five | |
|---|
| 398 | |
|---|
| 399 | |^|six|six| |
|---|
| 400 | HERE |
|---|
| 401 | }, |
|---|
| 402 | { |
|---|
| 403 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 404 | name => 'noppedWikiword', |
|---|
| 405 | html => '<p>!<span class="WYSIWYG_LINK">SunOS</span></p>', |
|---|
| 406 | tml => '!SunOS', |
|---|
| 407 | finaltml => '!SunOS', |
|---|
| 408 | }, |
|---|
| 409 | { |
|---|
| 410 | exec => $HTML2TML, |
|---|
| 411 | name => 'noppedPara', |
|---|
| 412 | html => "${nop}BeFore ${nop}SunOS ${nop}AfTer", |
|---|
| 413 | tml => '<nop>BeFore <nop>SunOS <nop>AfTer', |
|---|
| 414 | }, |
|---|
| 415 | { |
|---|
| 416 | exec => $HTML2TML, |
|---|
| 417 | name => 'noppedVariable', |
|---|
| 418 | html => <<HERE, |
|---|
| 419 | %${nop}MAINWEB%</nop> |
|---|
| 420 | HERE |
|---|
| 421 | tml => '%<nop>MAINWEB%' |
|---|
| 422 | }, |
|---|
| 423 | { |
|---|
| 424 | exec => $HTML2TML, #|$TML2HTML|$ROUNDTRIP, |
|---|
| 425 | name => 'noAutoLunk', |
|---|
| 426 | html => <<'HERE', |
|---|
| 427 | <p> |
|---|
| 428 | <span class="WYSIWYG_PROTECTED"><noautolink></span> |
|---|
| 429 | <span class="WYSIWYG_LINK">RedHat</span> & <span class="WYSIWYG_LINK">SuSE</span> |
|---|
| 430 | <span class="WYSIWYG_PROTECTED"></noautolink></span> |
|---|
| 431 | </p> |
|---|
| 432 | HERE |
|---|
| 433 | tml => <<'HERE', |
|---|
| 434 | <noautolink> |
|---|
| 435 | RedHat & SuSE |
|---|
| 436 | </noautolink> |
|---|
| 437 | HERE |
|---|
| 438 | finaltml => <<'HERE', |
|---|
| 439 | <noautolink> RedHat & SuSE </noautolink> |
|---|
| 440 | HERE |
|---|
| 441 | }, |
|---|
| 442 | { |
|---|
| 443 | exec => $ROUNDTRIP, |
|---|
| 444 | name => 'mailtoLink', |
|---|
| 445 | html => <<HERE, |
|---|
| 446 | $linkon\[[mailto:a\@z.com][Mail]]${linkoff} $linkon\[[mailto:?subject=Hi][Hi]]${linkoff} |
|---|
| 447 | HERE |
|---|
| 448 | tml => '[[mailto:a@z.com][Mail]] [[mailto:?subject=Hi][Hi]]', |
|---|
| 449 | finaltml => <<'HERE', |
|---|
| 450 | [[mailto:a@z.com][Mail]] [[mailto:?subject=Hi][Hi]] |
|---|
| 451 | HERE |
|---|
| 452 | }, |
|---|
| 453 | { |
|---|
| 454 | exec => $ROUNDTRIP, |
|---|
| 455 | name => 'mailtoLink2', |
|---|
| 456 | html => ' a@z.com ', |
|---|
| 457 | tml => 'a@z.com', |
|---|
| 458 | }, |
|---|
| 459 | { |
|---|
| 460 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 461 | name => 'variousWikiWords', |
|---|
| 462 | html => |
|---|
| 463 | "<p>${linkon}WebPreferences${linkoff}</p><p>$protecton<br />%MAINWEB%$protectoff.WikiUsers</p><p>${linkon}CompleteAndUtterNothing${linkoff}</p><p>${linkon}LinkBox$linkoff${linkon}LinkBoxs${linkoff}${linkon}LinkBoxies${linkoff}${linkon}LinkBoxess${linkoff}${linkon}LinkBoxesses${linkoff}${linkon}LinkBoxes${linkoff}</p>", |
|---|
| 464 | tml => <<'YYY', |
|---|
| 465 | WebPreferences |
|---|
| 466 | |
|---|
| 467 | %MAINWEB%.WikiUsers |
|---|
| 468 | |
|---|
| 469 | CompleteAndUtterNothing |
|---|
| 470 | |
|---|
| 471 | LinkBox LinkBoxs LinkBoxies LinkBoxess LinkBoxesses LinkBoxes |
|---|
| 472 | YYY |
|---|
| 473 | }, |
|---|
| 474 | { |
|---|
| 475 | exec => $HTML2TML | $ROUNDTRIP, |
|---|
| 476 | name => 'variousWikiWordsNopped', |
|---|
| 477 | html => |
|---|
| 478 | "${nop}${linkon}WebPreferences${linkoff} %${nop}MAINWEB%.WikiUsers ${nop}CompleteAndUtterNothing", |
|---|
| 479 | tml => |
|---|
| 480 | '<nop>WebPreferences %<nop>MAINWEB%.WikiUsers <nop>CompleteAndUtterNothing', |
|---|
| 481 | }, |
|---|
| 482 | { |
|---|
| 483 | exec => $ROUNDTRIP, |
|---|
| 484 | name => 'squabsWithVars', |
|---|
| 485 | html => <<HERE, |
|---|
| 486 | ${linkon}[[wiki syntax]]$linkoff$linkon\[[%MAINWEB%.TWiki users]]${linkoff} |
|---|
| 487 | escaped: |
|---|
| 488 | [<nop>[wiki syntax]] |
|---|
| 489 | HERE |
|---|
| 490 | tml => <<'THERE', |
|---|
| 491 | [[wiki syntax]][[%MAINWEB%.TWiki users]] |
|---|
| 492 | escaped: |
|---|
| 493 | ![[wiki syntax]] |
|---|
| 494 | THERE |
|---|
| 495 | finaltml => <<'EVERYWHERE', |
|---|
| 496 | [[wiki syntax]][[%MAINWEB%.TWiki users]] escaped: ![[wiki syntax]] |
|---|
| 497 | EVERYWHERE |
|---|
| 498 | }, |
|---|
| 499 | { |
|---|
| 500 | exec => $ROUNDTRIP, |
|---|
| 501 | name => 'squabsWithWikiWordsAndLink', |
|---|
| 502 | html => $linkon |
|---|
| 503 | . '[[WikiSyntax][syntax]]' |
|---|
| 504 | . $linkoff . ' ' |
|---|
| 505 | . $linkon |
|---|
| 506 | . '[[http://gnu.org][GNU]]' |
|---|
| 507 | . $linkoff . ' ' |
|---|
| 508 | . $linkon |
|---|
| 509 | . '[[http://xml.org][XML]]' |
|---|
| 510 | . $linkoff, |
|---|
| 511 | tml => |
|---|
| 512 | '[[WikiSyntax][syntax]] [[http://gnu.org][GNU]] [[http://xml.org][XML]]', |
|---|
| 513 | }, |
|---|
| 514 | { |
|---|
| 515 | exec => $ROUNDTRIP, |
|---|
| 516 | name => 'squabWithAnchor', |
|---|
| 517 | html => ${linkon} . 'FleegleHorn#TrumpetHack' . ${linkoff}, |
|---|
| 518 | tml => 'FleegleHorn#TrumpetHack', |
|---|
| 519 | }, |
|---|
| 520 | { |
|---|
| 521 | exec => $ROUNDTRIP, |
|---|
| 522 | name => 'plingedVarOne', |
|---|
| 523 | html => '!<span class="WYSIWYG_PROTECTED">%MAINWEB%</span>nowt', |
|---|
| 524 | tml => '!%MAINWEB%nowt', |
|---|
| 525 | finaltml => '!%MAINWEB%nowt', |
|---|
| 526 | }, |
|---|
| 527 | { |
|---|
| 528 | exec => $ROUNDTRIP, |
|---|
| 529 | name => 'plingedVarTwo', |
|---|
| 530 | html => 'nowt!<span class="WYSIWYG_PROTECTED">%MAINWEB%</span>', |
|---|
| 531 | tml => 'nowt!%MAINWEB%', |
|---|
| 532 | finaltml => 'nowt!%MAINWEB%', |
|---|
| 533 | }, |
|---|
| 534 | { |
|---|
| 535 | exec => $ROUNDTRIP, |
|---|
| 536 | name => 'headerly', |
|---|
| 537 | html => |
|---|
| 538 | "<h1 class='notoc'><span class='WYSIWYG_PROTECTED'>%TOPIC%</span></h1>", |
|---|
| 539 | tml => '---+!!%TOPIC%', |
|---|
| 540 | finaltml => '---+!! %TOPIC%', |
|---|
| 541 | }, |
|---|
| 542 | { |
|---|
| 543 | exec => $ROUNDTRIP, |
|---|
| 544 | name => 'WEBvar', |
|---|
| 545 | html => "${protecton}%WEB%${protectoff}", |
|---|
| 546 | tml => '%WEB%', |
|---|
| 547 | }, |
|---|
| 548 | { |
|---|
| 549 | exec => $ROUNDTRIP, |
|---|
| 550 | name => 'ICONvar1', |
|---|
| 551 | html => "${protecton}%ICON{}%${protectoff}", |
|---|
| 552 | tml => '%ICON{}%', |
|---|
| 553 | }, |
|---|
| 554 | { |
|---|
| 555 | exec => $ROUNDTRIP, |
|---|
| 556 | name => 'ICONvar2', |
|---|
| 557 | html => "${protecton}%ICON{""}%${protectoff}", |
|---|
| 558 | tml => '%ICON{""}%', |
|---|
| 559 | }, |
|---|
| 560 | { |
|---|
| 561 | exec => $ROUNDTRIP, |
|---|
| 562 | name => 'ICONvar3', |
|---|
| 563 | html => "${protecton}%ICON{"Fleegle"}%${protectoff}", |
|---|
| 564 | tml => '%ICON{"Fleegle"}%' |
|---|
| 565 | }, |
|---|
| 566 | { |
|---|
| 567 | exec => $ROUNDTRIP, |
|---|
| 568 | name => 'URLENCODEvar', |
|---|
| 569 | html => "${protecton}%URLENCODE{""}%${protectoff}", |
|---|
| 570 | tml => '%URLENCODE{""}%', |
|---|
| 571 | }, |
|---|
| 572 | { |
|---|
| 573 | exec => $ROUNDTRIP, |
|---|
| 574 | name => 'ENCODEvar', |
|---|
| 575 | html => "${protecton}%ENCODE{""}%${protectoff}", |
|---|
| 576 | tml => '%ENCODE{""}%', |
|---|
| 577 | }, |
|---|
| 578 | { |
|---|
| 579 | exec => $ROUNDTRIP, |
|---|
| 580 | name => 'INTURLENCODEvar', |
|---|
| 581 | html => "${protecton}%INTURLENCODE{""}%${protectoff}", |
|---|
| 582 | tml => '%INTURLENCODE{""}%', |
|---|
| 583 | }, |
|---|
| 584 | { |
|---|
| 585 | exec => $ROUNDTRIP, |
|---|
| 586 | name => 'USERSWEBvar', |
|---|
| 587 | html => "${protecton}%MAINWEB%${protectoff}", |
|---|
| 588 | tml => '%MAINWEB%', |
|---|
| 589 | }, |
|---|
| 590 | { |
|---|
| 591 | exec => $ROUNDTRIP, |
|---|
| 592 | name => 'SYSTEMWEBvar', |
|---|
| 593 | html => "${protecton}%SYSTEMWEB%${protectoff}", |
|---|
| 594 | tml => '%SYSTEMWEB%', |
|---|
| 595 | }, |
|---|
| 596 | { |
|---|
| 597 | exec => $ROUNDTRIP, |
|---|
| 598 | name => 'HOMETOPICvar', |
|---|
| 599 | html => "${protecton}%HOMETOPIC%${protectoff}", |
|---|
| 600 | tml => '%HOMETOPIC%', |
|---|
| 601 | }, |
|---|
| 602 | { |
|---|
| 603 | exec => $ROUNDTRIP, |
|---|
| 604 | name => 'WIKIUSERSTOPICvar', |
|---|
| 605 | html => $protecton . '%WIKIUSERSTOPIC%' . $protectoff, |
|---|
| 606 | tml => '%WIKIUSERSTOPIC%', |
|---|
| 607 | }, |
|---|
| 608 | { |
|---|
| 609 | exec => $ROUNDTRIP, |
|---|
| 610 | name => 'WIKIPREFSTOPICvar', |
|---|
| 611 | html => $protecton . '%WIKIPREFSTOPIC%' . $protectoff, |
|---|
| 612 | tml => '%WIKIPREFSTOPIC%', |
|---|
| 613 | }, |
|---|
| 614 | { |
|---|
| 615 | exec => $ROUNDTRIP, |
|---|
| 616 | name => 'WEBPREFSTOPICvar', |
|---|
| 617 | html => $protecton . '%WEBPREFSTOPIC%' . $protectoff, |
|---|
| 618 | tml => '%WEBPREFSTOPIC%', |
|---|
| 619 | }, |
|---|
| 620 | { |
|---|
| 621 | exec => $ROUNDTRIP, |
|---|
| 622 | name => 'NOTIFYTOPICvar', |
|---|
| 623 | html => $protecton . '%NOTIFYTOPIC%' . $protectoff, |
|---|
| 624 | tml => '%NOTIFYTOPIC%', |
|---|
| 625 | }, |
|---|
| 626 | { |
|---|
| 627 | exec => $ROUNDTRIP, |
|---|
| 628 | name => 'STATISTICSTOPICvar', |
|---|
| 629 | html => $protecton . '%STATISTICSTOPIC%' . $protectoff, |
|---|
| 630 | tml => '%STATISTICSTOPIC%', |
|---|
| 631 | }, |
|---|
| 632 | { |
|---|
| 633 | exec => $ROUNDTRIP, |
|---|
| 634 | name => 'STARTINCLUDEvar', |
|---|
| 635 | html => $protecton . '%STARTINCLUDE%' . $protectoff, |
|---|
| 636 | tml => '%STARTINCLUDE%', |
|---|
| 637 | }, |
|---|
| 638 | { |
|---|
| 639 | exec => $ROUNDTRIP, |
|---|
| 640 | name => 'STOPINCLUDEvar', |
|---|
| 641 | html => $protecton . '%STOPINCLUDE%' . $protectoff, |
|---|
| 642 | tml => '%STOPINCLUDE%', |
|---|
| 643 | }, |
|---|
| 644 | { |
|---|
| 645 | exec => $ROUNDTRIP, |
|---|
| 646 | name => 'SECTIONvar', |
|---|
| 647 | html => $protecton . '%SECTION{""}%' . $protectoff, |
|---|
| 648 | tml => '%SECTION{""}%', |
|---|
| 649 | }, |
|---|
| 650 | { |
|---|
| 651 | exec => $ROUNDTRIP, |
|---|
| 652 | name => 'ENDSECTIONvar', |
|---|
| 653 | html => $protecton . '%ENDSECTION%' . $protectoff, |
|---|
| 654 | tml => '%ENDSECTION%', |
|---|
| 655 | }, |
|---|
| 656 | { |
|---|
| 657 | exec => $ROUNDTRIP, |
|---|
| 658 | name => 'FORMFIELDvar1', |
|---|
| 659 | html => $protecton |
|---|
| 660 | . '%FORMFIELD{"" topic="" alttext="" default="" format="$value"}%' |
|---|
| 661 | . $protectoff, |
|---|
| 662 | tml => '%FORMFIELD{"" topic="" alttext="" default="" format="$value"}%', |
|---|
| 663 | }, |
|---|
| 664 | { |
|---|
| 665 | exec => $ROUNDTRIP, |
|---|
| 666 | name => 'FORMFIELDvar2', |
|---|
| 667 | html => $protecton |
|---|
| 668 | . '%FORMFIELD{"TopicClassification" topic="" alttext="" default="" format="$value"}%' |
|---|
| 669 | . $protectoff, |
|---|
| 670 | tml => |
|---|
| 671 | '%FORMFIELD{"TopicClassification" topic="" alttext="" default="" format="$value"}%', |
|---|
| 672 | }, |
|---|
| 673 | { |
|---|
| 674 | exec => $ROUNDTRIP, |
|---|
| 675 | name => 'SPACEDTOPICvar', |
|---|
| 676 | html => $protecton . '%SPACEDTOPIC%' . $protectoff, |
|---|
| 677 | tml => '%SPACEDTOPIC%', |
|---|
| 678 | }, |
|---|
| 679 | { |
|---|
| 680 | exec => $ROUNDTRIP, |
|---|
| 681 | name => 'RELATIVETOPICPATHvar1', |
|---|
| 682 | html => $protecton . '%RELATIVETOPICPATH{}%' . $protectoff, |
|---|
| 683 | tml => '%RELATIVETOPICPATH{}%', |
|---|
| 684 | }, |
|---|
| 685 | { |
|---|
| 686 | exec => $ROUNDTRIP, |
|---|
| 687 | name => 'RELATIVETOPICPATHvar2', |
|---|
| 688 | html => $protecton . '%RELATIVETOPICPATH{Sausage}%' . $protectoff, |
|---|
| 689 | tml => '%RELATIVETOPICPATH{Sausage}%', |
|---|
| 690 | }, |
|---|
| 691 | { |
|---|
| 692 | exec => $ROUNDTRIP, |
|---|
| 693 | name => 'RELATIVETOPICPATHvar3', |
|---|
| 694 | html => $protecton |
|---|
| 695 | . '%RELATIVETOPICPATH{"Chips"}%' |
|---|
| 696 | . $protectoff, |
|---|
| 697 | tml => '%RELATIVETOPICPATH{"Chips"}%', |
|---|
| 698 | }, |
|---|
| 699 | { |
|---|
| 700 | exec => $ROUNDTRIP, |
|---|
| 701 | name => 'SCRIPTNAMEvar', |
|---|
| 702 | html => $protecton . '%SCRIPTNAME%' . $protectoff, |
|---|
| 703 | tml => '%SCRIPTNAME%', |
|---|
| 704 | }, |
|---|
| 705 | { |
|---|
| 706 | exec => $ROUNDTRIP, |
|---|
| 707 | name => 'nestedVerbatim', |
|---|
| 708 | html => 'Outside |
|---|
| 709 | <span class="TMLverbatim"><br />Inside<br /></span>Outside', |
|---|
| 710 | tml => 'Outside |
|---|
| 711 | <verbatim> |
|---|
| 712 | Inside |
|---|
| 713 | </verbatim> |
|---|
| 714 | Outside', |
|---|
| 715 | finaltml => 'Outside <verbatim> |
|---|
| 716 | Inside |
|---|
| 717 | </verbatim> Outside', |
|---|
| 718 | }, |
|---|
| 719 | { |
|---|
| 720 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 721 | name => 'nestedPre', |
|---|
| 722 | html => '<p> |
|---|
| 723 | Outside <pre class="foswikiAlert TMLverbatim"><br /> Inside<br /> </pre> Outside </p>', |
|---|
| 724 | tml => 'Outside <verbatim class="foswikiAlert"> |
|---|
| 725 | Inside |
|---|
| 726 | </verbatim> Outside', |
|---|
| 727 | }, |
|---|
| 728 | { |
|---|
| 729 | exec => $ROUNDTRIP, |
|---|
| 730 | name => 'nestedIndentedVerbatim', |
|---|
| 731 | html => |
|---|
| 732 | 'Outside<span class="TMLverbatim"><br />Inside<br /> </span>Outside', |
|---|
| 733 | tml => 'Outside |
|---|
| 734 | <verbatim> |
|---|
| 735 | Inside |
|---|
| 736 | </verbatim> |
|---|
| 737 | Outside |
|---|
| 738 | ', |
|---|
| 739 | finaltml => 'Outside <verbatim> |
|---|
| 740 | Inside |
|---|
| 741 | </verbatim> Outside', |
|---|
| 742 | }, |
|---|
| 743 | { |
|---|
| 744 | exec => $ROUNDTRIP | $HTML2TML, |
|---|
| 745 | name => 'nestedIndentedPre', |
|---|
| 746 | html => 'Outside |
|---|
| 747 | <pre> |
|---|
| 748 | Inside |
|---|
| 749 | |
|---|
| 750 | Snide |
|---|
| 751 | </pre> |
|---|
| 752 | Outside', |
|---|
| 753 | tml => 'Outside |
|---|
| 754 | <pre> |
|---|
| 755 | Inside |
|---|
| 756 | |
|---|
| 757 | Snide |
|---|
| 758 | </pre> |
|---|
| 759 | Outside', |
|---|
| 760 | finaltml => 'Outside <pre> |
|---|
| 761 | Inside |
|---|
| 762 | |
|---|
| 763 | Snide |
|---|
| 764 | </pre> Outside', |
|---|
| 765 | }, |
|---|
| 766 | { |
|---|
| 767 | exec => $HTML2TML, |
|---|
| 768 | name => 'classifiedPre', |
|---|
| 769 | html => 'Outside |
|---|
| 770 | <pre class="foswikiAlert"> |
|---|
| 771 | Inside |
|---|
| 772 | </pre> |
|---|
| 773 | Outside', |
|---|
| 774 | tml => 'Outside <pre class="foswikiAlert"> |
|---|
| 775 | Inside |
|---|
| 776 | </pre> Outside', |
|---|
| 777 | }, |
|---|
| 778 | { |
|---|
| 779 | exec => $ROUNDTRIP, |
|---|
| 780 | name => 'indentedPre', |
|---|
| 781 | html => 'Outside<pre> |
|---|
| 782 | Inside |
|---|
| 783 | </pre>Outside', |
|---|
| 784 | tml => 'Outside |
|---|
| 785 | <pre> |
|---|
| 786 | Inside |
|---|
| 787 | </pre> |
|---|
| 788 | Outside', |
|---|
| 789 | finaltml => 'Outside <pre> |
|---|
| 790 | Inside |
|---|
| 791 | </pre> Outside', |
|---|
| 792 | }, |
|---|
| 793 | { |
|---|
| 794 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 795 | name => 'NAL', |
|---|
| 796 | html => '<p>Outside |
|---|
| 797 | <span class="WYSIWYG_PROTECTED"><noautolink></span> |
|---|
| 798 | Inside |
|---|
| 799 | <span class="WYSIWYG_PROTECTED"></noautolink></span> |
|---|
| 800 | Outside</p>', |
|---|
| 801 | tml => 'Outside |
|---|
| 802 | <noautolink> |
|---|
| 803 | Inside |
|---|
| 804 | </noautolink> |
|---|
| 805 | Outside', |
|---|
| 806 | finaltml => 'Outside <noautolink> Inside </noautolink> Outside', |
|---|
| 807 | }, |
|---|
| 808 | { |
|---|
| 809 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 810 | name => 'classifiedNAL', |
|---|
| 811 | html => '<p>Outside |
|---|
| 812 | <span class="WYSIWYG_PROTECTED"><noautolink class="foswikiAlert"></span></p> |
|---|
| 813 | <ul> |
|---|
| 814 | <li> Inside </li> |
|---|
| 815 | </ul> |
|---|
| 816 | <span class="WYSIWYG_PROTECTED"></noautolink></span> |
|---|
| 817 | Outside |
|---|
| 818 | ', |
|---|
| 819 | tml => 'Outside |
|---|
| 820 | <noautolink class="foswikiAlert"> |
|---|
| 821 | * Inside |
|---|
| 822 | </noautolink> |
|---|
| 823 | Outside', |
|---|
| 824 | finaltml => 'Outside <noautolink class="foswikiAlert"> |
|---|
| 825 | * Inside |
|---|
| 826 | </noautolink> Outside', |
|---|
| 827 | }, |
|---|
| 828 | { |
|---|
| 829 | exec => $ROUNDTRIP, |
|---|
| 830 | name => 'indentedNAL', |
|---|
| 831 | html => 'Outside |
|---|
| 832 | <span class="WYSIWYG_PROTECTED"><noautolink></span> |
|---|
| 833 | Inside |
|---|
| 834 | <span class="WYSIWYG_PROTECTED"></noautolink></span> |
|---|
| 835 | Outside |
|---|
| 836 | ', |
|---|
| 837 | tml => 'Outside |
|---|
| 838 | <noautolink> |
|---|
| 839 | Inside |
|---|
| 840 | </noautolink> |
|---|
| 841 | Outside |
|---|
| 842 | ', |
|---|
| 843 | finaltml => 'Outside <noautolink> Inside </noautolink> Outside', |
|---|
| 844 | }, |
|---|
| 845 | { |
|---|
| 846 | exec => $ROUNDTRIP, |
|---|
| 847 | name => 'linkInHeader', |
|---|
| 848 | html => |
|---|
| 849 | "<h3 class=\"TML\"> Test with${linkon}LinkInHeader${linkoff}</h3>", |
|---|
| 850 | tml => '---+++ Test with LinkInHeader', |
|---|
| 851 | }, |
|---|
| 852 | { |
|---|
| 853 | exec => $HTML2TML, |
|---|
| 854 | name => 'inlineBreaks', |
|---|
| 855 | html => 'Zadoc<br />The<br />Priest', |
|---|
| 856 | finaltml => 'Zadoc<br />The<br />Priest', |
|---|
| 857 | }, |
|---|
| 858 | { |
|---|
| 859 | exec => $HTML2TML, |
|---|
| 860 | name => 'doctype', |
|---|
| 861 | html => |
|---|
| 862 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', |
|---|
| 863 | tml => '', |
|---|
| 864 | }, |
|---|
| 865 | { |
|---|
| 866 | exec => $HTML2TML, |
|---|
| 867 | name => 'head', |
|---|
| 868 | html => '<head> ignore me </head>', |
|---|
| 869 | tml => '', |
|---|
| 870 | }, |
|---|
| 871 | { |
|---|
| 872 | exec => $HTML2TML, |
|---|
| 873 | name => 'htmlAndBody', |
|---|
| 874 | html => '<html> good <body>good </body></html>', |
|---|
| 875 | tml => 'good good', |
|---|
| 876 | }, |
|---|
| 877 | { |
|---|
| 878 | exec => $HTML2TML, |
|---|
| 879 | name => 'kupuTable', |
|---|
| 880 | html => |
|---|
| 881 | '<table cellspacing="0" cellpadding="8" border="1" class="plain" _moz_resizing="true"> |
|---|
| 882 | <tbody> |
|---|
| 883 | <tr>a0<td>a1</td><td>a2</td><td>a3</td></tr> |
|---|
| 884 | <tr>b0<td colspan="2">b1</td><td>b3</td></tr> |
|---|
| 885 | <tr>c0<td>c1</td><td>c2</td><td>c3</td></tr> |
|---|
| 886 | </tbody> |
|---|
| 887 | </table>', |
|---|
| 888 | tml => '| a1 | a2 | a3 | |
|---|
| 889 | | b1 || b3 | |
|---|
| 890 | | c1 | c2 | c3 | |
|---|
| 891 | ', |
|---|
| 892 | }, |
|---|
| 893 | { |
|---|
| 894 | exec => $ROUNDTRIP, |
|---|
| 895 | name => "images", |
|---|
| 896 | html => '<img src="test_image" />', |
|---|
| 897 | tml => '%TRANSLATEDIMAGE%', |
|---|
| 898 | }, |
|---|
| 899 | { |
|---|
| 900 | exec => $ROUNDTRIP, |
|---|
| 901 | name => "TWikiTagsInHTMLParam", |
|---|
| 902 | html => "${linkon}[[%!page!%/Burble/Barf][Burble]]${linkoff}", |
|---|
| 903 | tml => '[[%!page!%/Burble/Barf][Burble]]', |
|---|
| 904 | }, |
|---|
| 905 | { |
|---|
| 906 | exec => $HTML2TML, |
|---|
| 907 | name => "emptySpans", |
|---|
| 908 | html => <<HERE, |
|---|
| 909 | 1 <span class="arfle"></span> |
|---|
| 910 | 2 <span lang="jp"></span> |
|---|
| 911 | 3 <span></span> |
|---|
| 912 | 4 <span style="chanel">francais</span> |
|---|
| 913 | 5 <span class="fr">francais</span> |
|---|
| 914 | HERE |
|---|
| 915 | tml => <<HERE, |
|---|
| 916 | 1 2 3 4 <span style="chanel">francais</span> 5 francais |
|---|
| 917 | HERE |
|---|
| 918 | }, |
|---|
| 919 | { |
|---|
| 920 | exec => $ROUNDTRIP, |
|---|
| 921 | name => 'linkToOtherWeb', |
|---|
| 922 | html => "${linkon}[[Sandbox.WebHome][this]]${linkoff}", |
|---|
| 923 | tml => '[[Sandbox.WebHome][this]]', |
|---|
| 924 | }, |
|---|
| 925 | { |
|---|
| 926 | exec => $ROUNDTRIP, |
|---|
| 927 | name => 'anchoredLink', |
|---|
| 928 | tml => '[[FAQ.NetworkInternet#Pomona_Network][Test Link]]', |
|---|
| 929 | html => |
|---|
| 930 | "${linkon}[[FAQ.NetworkInternet#Pomona_Network][Test Link]]${linkoff}", |
|---|
| 931 | }, |
|---|
| 932 | { |
|---|
| 933 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 934 | name => 'tableWithColSpans', |
|---|
| 935 | html => '<p>abcd |
|---|
| 936 | </p> |
|---|
| 937 | <table cellspacing="1" cellpadding="0" border="1"> |
|---|
| 938 | <tr><td colspan="2">efg</td><td> </td></tr> |
|---|
| 939 | <tr><td colspan="3"></td></tr></table> |
|---|
| 940 | hijk', |
|---|
| 941 | tml => 'abcd |
|---|
| 942 | | efg || | |
|---|
| 943 | |||| |
|---|
| 944 | hijk', |
|---|
| 945 | finaltml => 'abcd |
|---|
| 946 | | efg || | |
|---|
| 947 | | ||| |
|---|
| 948 | hijk', |
|---|
| 949 | }, |
|---|
| 950 | { |
|---|
| 951 | exec => $ROUNDTRIP, |
|---|
| 952 | name => 'variableInIMGtag', |
|---|
| 953 | html => '<img src="/MAIN/pub/Current/TestTopic/T-logo-16x16.gif" />', |
|---|
| 954 | tml => '<img src="%ATTACHURLPATH%/T-logo-16x16.gif" />', |
|---|
| 955 | finaltml => '<img src="%ATTACHURLPATH%/T-logo-16x16.gif" />', |
|---|
| 956 | }, |
|---|
| 957 | { |
|---|
| 958 | exec => $TML2HTML | $HTML2TML | $ROUNDTRIP, |
|---|
| 959 | name => 'setCommand', |
|---|
| 960 | tml => <<HERE, |
|---|
| 961 | * Set FLIBBLE = <break> <cake/> |
|---|
| 962 | </break> |
|---|
| 963 | * %FLIBBLE% |
|---|
| 964 | * Set FLEEGLE = easy gum |
|---|
| 965 | HERE |
|---|
| 966 | html => '<ul> |
|---|
| 967 | <li> Set FLIBBLE =<span class="WYSIWYG_PROTECTED"> <break> <cake/><br /> </break></span></li><li><span class="WYSIWYG_PROTECTED">%FLIBBLE%</span><ul><li>Set FLEEGLE =<span class="WYSIWYG_PROTECTED"> easy gum</span></li></ul></li></ul>', |
|---|
| 968 | }, |
|---|
| 969 | { |
|---|
| 970 | exec => $HTML2TML, |
|---|
| 971 | name => 'tinyMCESetCommand', |
|---|
| 972 | tml => <<HERE, |
|---|
| 973 | Before |
|---|
| 974 | |
|---|
| 975 | * Set FLIBBLE = phlegm |
|---|
| 976 | After |
|---|
| 977 | HERE |
|---|
| 978 | html => |
|---|
| 979 | 'Before<p class="WYSIWYG_PROTECTED"> * Set FLIBBLE = phlegm</p>After', |
|---|
| 980 | }, |
|---|
| 981 | { |
|---|
| 982 | exec => $ROUNDTRIP, |
|---|
| 983 | name => 'twikiWebSnarf', |
|---|
| 984 | html => $linkon . '[[%SYSTEMWEB%.TopicName][bah]]' . $linkoff, |
|---|
| 985 | tml => '[[%SYSTEMWEB%.TopicName][bah]]', |
|---|
| 986 | }, |
|---|
| 987 | { |
|---|
| 988 | exec => $ROUNDTRIP, |
|---|
| 989 | name => 'mainWebSnarf', |
|---|
| 990 | html => "${linkon}\[[%MAINWEB%.TopicName][bah]]$linkoff", |
|---|
| 991 | tml => '[[%MAINWEB%.TopicName][bah]]', |
|---|
| 992 | }, |
|---|
| 993 | { |
|---|
| 994 | exec => $ROUNDTRIP, |
|---|
| 995 | name => 'mainFormWithVars', |
|---|
| 996 | html => $protecton |
|---|
| 997 | . '<form action="%SCRIPTURLPATH%/search%SCRIPTSUFFIX%/%INTURLENCODE{"%WEB%"}%/">' |
|---|
| 998 | . $protectoff, |
|---|
| 999 | tml => |
|---|
| 1000 | '<form action="%SCRIPTURLPATH%/search%SCRIPTSUFFIX%/%INTURLENCODE{"%WEB%"}%/">', |
|---|
| 1001 | }, |
|---|
| 1002 | { |
|---|
| 1003 | exec => $ROUNDTRIP, |
|---|
| 1004 | name => "Item871", |
|---|
| 1005 | tml => "[[Test]] Entry [[TestPage][Test Page]]\n", |
|---|
| 1006 | html => |
|---|
| 1007 | "${linkon}[[Test]]${linkoff} Entry ${linkon}[[TestPage][Test Page]]${linkoff}", |
|---|
| 1008 | }, |
|---|
| 1009 | { |
|---|
| 1010 | exec => 0, |
|---|
| 1011 | name => "Item863", |
|---|
| 1012 | tml => <<EOE, |
|---|
| 1013 | ||1| 2 | 3 | 4 || |
|---|
| 1014 | EOE |
|---|
| 1015 | html => '<table cellpadding="0" border="1" cellspacing="1">', |
|---|
| 1016 | finaltml => <<EOE, |
|---|
| 1017 | EOE |
|---|
| 1018 | }, |
|---|
| 1019 | { |
|---|
| 1020 | exec => $ROUNDTRIP, |
|---|
| 1021 | name => 'Item945', |
|---|
| 1022 | html => $protecton |
|---|
| 1023 | . '%SEARCH{"ReqNo" scope="topic" regex="on" nosearch="on" nototal="on" casesensitive="on" format="$percntCALC{$IF($NOT($FIND(%TOPIC%,$formfield(ReqParents))), <nop>, [[$topic]] - $formfield(ReqShortDescript) %BR% )}$percnt"}%' |
|---|
| 1024 | . $protectoff, |
|---|
| 1025 | tml => |
|---|
| 1026 | '%SEARCH{"ReqNo" scope="topic" regex="on" nosearch="on" nototal="on" casesensitive="on" format="$percntCALC{$IF($NOT($FIND(%TOPIC%,$formfield(ReqParents))), <nop>, [[$topic]] - $formfield(ReqShortDescript) %BR% )}$percnt"}%', |
|---|
| 1027 | }, |
|---|
| 1028 | { |
|---|
| 1029 | exec => $ROUNDTRIP, |
|---|
| 1030 | name => "WebAndTopic", |
|---|
| 1031 | tml => |
|---|
| 1032 | "Current.TestTopic Sandbox.TestTopic [[Current.TestTopic]] [[Sandbox.TestTopic]]", |
|---|
| 1033 | html => <<HERE, |
|---|
| 1034 | ${linkon}Current.TestTopic${linkoff} |
|---|
| 1035 | ${linkon}Sandbox.TestTopic${linkoff} |
|---|
| 1036 | ${linkon}\[[Current.TestTopic]]${linkoff} |
|---|
| 1037 | ${linkon}\[[Sandbox.TestTopic]]${linkoff} |
|---|
| 1038 | HERE |
|---|
| 1039 | finaltml => <<HERE, |
|---|
| 1040 | Current.TestTopic Sandbox.TestTopic [[Current.TestTopic]] [[Sandbox.TestTopic]] |
|---|
| 1041 | HERE |
|---|
| 1042 | }, |
|---|
| 1043 | { |
|---|
| 1044 | exec => $ROUNDTRIP, |
|---|
| 1045 | name => 'Item1140', |
|---|
| 1046 | html => '<img src="%!page!%/T-logo-16x16.gif" />', |
|---|
| 1047 | tml => '<img src="%!page!%/T-logo-16x16.gif" />', |
|---|
| 1048 | finaltml => '<img src=\'%SCRIPTURL{"view"}%/T-logo-16x16.gif\' />', |
|---|
| 1049 | }, |
|---|
| 1050 | { |
|---|
| 1051 | exec => $ROUNDTRIP, |
|---|
| 1052 | name => 'Item1175', |
|---|
| 1053 | tml => '[[WebCTPasswords][Resetting a WebCT Password]]', |
|---|
| 1054 | html => |
|---|
| 1055 | "${linkon}[[WebCTPasswords][Resetting a WebCT Password]]${linkoff}", |
|---|
| 1056 | finaltml => '[[WebCTPasswords][Resetting a WebCT Password]]', |
|---|
| 1057 | }, |
|---|
| 1058 | { |
|---|
| 1059 | exec => $ROUNDTRIP, |
|---|
| 1060 | name => 'Item1259', |
|---|
| 1061 | html => |
|---|
| 1062 | "Spleem$protecton<!--<br /> * Set SPOG = dreep<br />-->${protectoff}Splom", |
|---|
| 1063 | tml => "Spleem<!--\n * Set SPOG = dreep\n-->Splom", |
|---|
| 1064 | }, |
|---|
| 1065 | { |
|---|
| 1066 | exec => $ROUNDTRIP, |
|---|
| 1067 | name => 'Item1317', |
|---|
| 1068 | tml => '%<nop>DISPLAYTIME{"$hou:$min"}%', |
|---|
| 1069 | html => "%${nop}DISPLAYTIME\{\"\$hou:\$min\"}%", |
|---|
| 1070 | }, |
|---|
| 1071 | { |
|---|
| 1072 | exec => $ROUNDTRIP, |
|---|
| 1073 | name => 'Item4410', |
|---|
| 1074 | tml => <<'HERE', |
|---|
| 1075 | * x |
|---|
| 1076 | | Y | |
|---|
| 1077 | HERE |
|---|
| 1078 | html => |
|---|
| 1079 | '<ul><li>x</li></ul><table cellspacing="1" cellpadding="0" border="1"><tr><td>Y</td></tr></table>', |
|---|
| 1080 | }, |
|---|
| 1081 | { |
|---|
| 1082 | exec => $ROUNDTRIP, |
|---|
| 1083 | name => 'Item4426', |
|---|
| 1084 | tml => <<'HERE', |
|---|
| 1085 | * x |
|---|
| 1086 | * |
|---|
| 1087 | * y |
|---|
| 1088 | HERE |
|---|
| 1089 | html => '<ul> |
|---|
| 1090 | <li>x |
|---|
| 1091 | </li><li></li><li>y |
|---|
| 1092 | </li></ul>', |
|---|
| 1093 | finaltml => <<'HERE', |
|---|
| 1094 | * x |
|---|
| 1095 | * |
|---|
| 1096 | * y |
|---|
| 1097 | HERE |
|---|
| 1098 | }, |
|---|
| 1099 | { |
|---|
| 1100 | exec => $HTML2TML | $ROUNDTRIP, |
|---|
| 1101 | name => 'Item3735', |
|---|
| 1102 | tml => "fred *%WIKINAME%* fred", |
|---|
| 1103 | html => "<p>fred <b>$protecton%WIKINAME%$protectoff</b> fred</p>", |
|---|
| 1104 | }, |
|---|
| 1105 | { |
|---|
| 1106 | exec => $ROUNDTRIP, |
|---|
| 1107 | name => 'brInProtectedRegion', |
|---|
| 1108 | html => $protecton |
|---|
| 1109 | . "<!--Fred<br />Jo e<br />Sam-->" |
|---|
| 1110 | . $protectoff, |
|---|
| 1111 | tml => "<!--Fred\nJo e\nSam-->", |
|---|
| 1112 | }, |
|---|
| 1113 | { |
|---|
| 1114 | exec => $HTML2TML, |
|---|
| 1115 | name => 'whatTheF', |
|---|
| 1116 | html => 'what<p></p>thef', |
|---|
| 1117 | finaltml => "what\n\nthef", |
|---|
| 1118 | }, |
|---|
| 1119 | { |
|---|
| 1120 | exec => $ROUNDTRIP, |
|---|
| 1121 | name => 'whatTheFur', |
|---|
| 1122 | html => 'what<p />thef', |
|---|
| 1123 | tml => "what\n\nthef", |
|---|
| 1124 | }, |
|---|
| 1125 | { |
|---|
| 1126 | exec => $HTML2TML, # | $ROUNDTRIP, |
|---|
| 1127 | name => 'Item4435', |
|---|
| 1128 | html => <<HTML, |
|---|
| 1129 | <ul> |
|---|
| 1130 | <li> Clean up toolbar |
|---|
| 1131 | </li> |
|---|
| 1132 | <li> Test tools |
|---|
| 1133 | </li> |
|---|
| 1134 | </ul> |
|---|
| 1135 | Garbles Bargles Smargles |
|---|
| 1136 | <p> |
|---|
| 1137 | Flame grilled |
|---|
| 1138 | </p> |
|---|
| 1139 | <p> |
|---|
| 1140 | -- <span class="WYSIWYG_LINK">Main.JohnSilver</span> - 05 Aug 2007 |
|---|
| 1141 | </p> |
|---|
| 1142 | <p> |
|---|
| 1143 | Extra spaces??? |
|---|
| 1144 | </p> |
|---|
| 1145 | <p> |
|---|
| 1146 | <span class="WYSIWYG_PROTECTED">%COMMENT%</span> |
|---|
| 1147 | </p> |
|---|
| 1148 | HTML |
|---|
| 1149 | tml => <<TML, |
|---|
| 1150 | * Clean up toolbar |
|---|
| 1151 | * Test tools |
|---|
| 1152 | Garbles Bargles Smargles |
|---|
| 1153 | |
|---|
| 1154 | Flame grilled |
|---|
| 1155 | |
|---|
| 1156 | -- Main.JohnSilver - 05 Aug 2007 |
|---|
| 1157 | |
|---|
| 1158 | Extra spaces??? |
|---|
| 1159 | |
|---|
| 1160 | %COMMENT% |
|---|
| 1161 | TML |
|---|
| 1162 | }, |
|---|
| 1163 | { |
|---|
| 1164 | name => 'paraConversions1', |
|---|
| 1165 | exec => $TML2HTML | $HTML2TML | $ROUNDTRIP, |
|---|
| 1166 | html => '<p> |
|---|
| 1167 | Paraone |
|---|
| 1168 | Paratwo |
|---|
| 1169 | </p> |
|---|
| 1170 | <p> |
|---|
| 1171 | Parathree |
|---|
| 1172 | </p> |
|---|
| 1173 | <p></p> |
|---|
| 1174 | <p> |
|---|
| 1175 | Parafour |
|---|
| 1176 | </p>', |
|---|
| 1177 | tml => 'Paraone |
|---|
| 1178 | Paratwo |
|---|
| 1179 | |
|---|
| 1180 | Parathree |
|---|
| 1181 | |
|---|
| 1182 | |
|---|
| 1183 | Parafour', |
|---|
| 1184 | finaltml => 'Paraone Paratwo |
|---|
| 1185 | |
|---|
| 1186 | Parathree |
|---|
| 1187 | |
|---|
| 1188 | Parafour', |
|---|
| 1189 | }, |
|---|
| 1190 | { |
|---|
| 1191 | name => 'paraConversionsTinyMCE', |
|---|
| 1192 | exec => $HTML2TML, |
|---|
| 1193 | html => 'Paraone |
|---|
| 1194 | Paratwo |
|---|
| 1195 | <p> </p> |
|---|
| 1196 | Parathree |
|---|
| 1197 | <p> </p> |
|---|
| 1198 | <p> </p> |
|---|
| 1199 | Parafour', |
|---|
| 1200 | tml => 'Paraone |
|---|
| 1201 | Paratwo |
|---|
| 1202 | |
|---|
| 1203 | Parathree |
|---|
| 1204 | |
|---|
| 1205 | Parafour', |
|---|
| 1206 | finaltml => 'Paraone Paratwo |
|---|
| 1207 | |
|---|
| 1208 | Parathree |
|---|
| 1209 | |
|---|
| 1210 | Parafour', |
|---|
| 1211 | }, |
|---|
| 1212 | { |
|---|
| 1213 | name => 'paraAfterList', |
|---|
| 1214 | exec => $HTML2TML | $ROUNDTRIP, |
|---|
| 1215 | tml => ' * list |
|---|
| 1216 | Paraone', |
|---|
| 1217 | html => '<ul><li>list</li></ul>Paraone', |
|---|
| 1218 | }, |
|---|
| 1219 | { |
|---|
| 1220 | name => 'brInText', |
|---|
| 1221 | exec => $HTML2TML, |
|---|
| 1222 | tml => 'pilf<br />flip', |
|---|
| 1223 | html => 'pilf<br>flip', |
|---|
| 1224 | }, |
|---|
| 1225 | { |
|---|
| 1226 | name => 'brInSource', |
|---|
| 1227 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 1228 | tml => 'pilf<br />flip', |
|---|
| 1229 | html => '<p> |
|---|
| 1230 | pilf<br />flip |
|---|
| 1231 | </p>', |
|---|
| 1232 | }, |
|---|
| 1233 | { |
|---|
| 1234 | name => 'Item4481', |
|---|
| 1235 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 1236 | tml => '<blockquote>pilf<br />flip</blockquote>', |
|---|
| 1237 | html => '<p><blockquote>pilf<br />flip</blockquote></p>', |
|---|
| 1238 | }, |
|---|
| 1239 | { |
|---|
| 1240 | exec => $ROUNDTRIP, |
|---|
| 1241 | name => 'wtf', |
|---|
| 1242 | html => <<"HERE", |
|---|
| 1243 | <ol><li>w$protecton<br />${protectoff}g</li></ol> |
|---|
| 1244 | HERE |
|---|
| 1245 | tml => <<'HERE', |
|---|
| 1246 | 1 w<br />g |
|---|
| 1247 | HERE |
|---|
| 1248 | }, |
|---|
| 1249 | { |
|---|
| 1250 | exec => $ROUNDTRIP | $HTML2TML, |
|---|
| 1251 | name => 'blah', |
|---|
| 1252 | html => '<ul> |
|---|
| 1253 | <li> Prevent |
|---|
| 1254 | <ul> |
|---|
| 1255 | <li> Set NOAUTOLINK =<span class="WYSIWYG_PROTECTED"></span> |
|---|
| 1256 | </li> |
|---|
| 1257 | </ul> |
|---|
| 1258 | </li> |
|---|
| 1259 | <li> The <code><span class="WYSIWYG_PROTECTED"><noautolink></span>...<span class="WYSIWYG_PROTECTED"></noautolink></span></code> syntax |
|---|
| 1260 | </li> |
|---|
| 1261 | </ul> |
|---|
| 1262 | ', |
|---|
| 1263 | tml => ' * Prevent |
|---|
| 1264 | * Set NOAUTOLINK = |
|---|
| 1265 | * The <code><noautolink>...</noautolink></code> syntax |
|---|
| 1266 | ', |
|---|
| 1267 | finaltml => ' * Prevent |
|---|
| 1268 | * Set NOAUTOLINK = |
|---|
| 1269 | * The =<noautolink>...</noautolink>= syntax |
|---|
| 1270 | ', |
|---|
| 1271 | }, |
|---|
| 1272 | { |
|---|
| 1273 | exec => $HTML2TML, |
|---|
| 1274 | name => 'losethatdamnBR', |
|---|
| 1275 | html => <<'JUNK', |
|---|
| 1276 | TinyMCE sticks in a BR where it isn't wanted before a P<br> |
|---|
| 1277 | <p> |
|---|
| 1278 | We should only have a P. |
|---|
| 1279 | </p> |
|---|
| 1280 | JUNK |
|---|
| 1281 | tml => <<JUNX, |
|---|
| 1282 | TinyMCE sticks in a BR where it isn't wanted before a P |
|---|
| 1283 | |
|---|
| 1284 | We should only have a P. |
|---|
| 1285 | JUNX |
|---|
| 1286 | }, |
|---|
| 1287 | { |
|---|
| 1288 | exec => $HTML2TML, |
|---|
| 1289 | name => 'tableInnaBun', |
|---|
| 1290 | html => <<'JUNK', |
|---|
| 1291 | <ul> |
|---|
| 1292 | <li> List item</li><li><table><tbody><tr><td> 11</td><td> 21</td></tr><tr><td>12 </td><td> 22</td></tr></tbody></table></li><li>crap</li> |
|---|
| 1293 | </ul> |
|---|
| 1294 | JUNK |
|---|
| 1295 | tml => <<JUNX, |
|---|
| 1296 | * List item |
|---|
| 1297 | * <table><tbody><tr><td> 11</td><td> 21</td></tr><tr><td>12 </td><td> 22</td></tr></tbody></table> |
|---|
| 1298 | * crap |
|---|
| 1299 | JUNX |
|---|
| 1300 | }, |
|---|
| 1301 | { |
|---|
| 1302 | exec => $HTML2TML, |
|---|
| 1303 | name => 'Item4560', |
|---|
| 1304 | html => <<JUNSK, |
|---|
| 1305 | Here is some text. Here a new line of text. |
|---|
| 1306 | <p> |
|---|
| 1307 | If you edit this page with TMCE, then save it, this line will become part of the previous paragraph. |
|---|
| 1308 | </p> |
|---|
| 1309 | JUNSK |
|---|
| 1310 | tml => <<JUNSX, |
|---|
| 1311 | Here is some text. Here a new line of text. |
|---|
| 1312 | |
|---|
| 1313 | If you edit this page with TMCE, then save it, this line will become part of the previous paragraph. |
|---|
| 1314 | JUNSX |
|---|
| 1315 | }, |
|---|
| 1316 | { |
|---|
| 1317 | exec => $TML2HTML, |
|---|
| 1318 | name => 'Item4550', |
|---|
| 1319 | tml => <<FGFG, |
|---|
| 1320 | ---+ A |
|---|
| 1321 | <section> |
|---|
| 1322 | ---++ B |
|---|
| 1323 | C |
|---|
| 1324 | </section> |
|---|
| 1325 | X |
|---|
| 1326 | FGFG |
|---|
| 1327 | html => '<h1 class="TML"> A </h1> |
|---|
| 1328 | <span class="WYSIWYG_PROTECTED"><section></span> |
|---|
| 1329 | <h2 class="TML"> B </h2> |
|---|
| 1330 | C |
|---|
| 1331 | <span class="WYSIWYG_PROTECTED"></section></span> |
|---|
| 1332 | X |
|---|
| 1333 | ', |
|---|
| 1334 | }, |
|---|
| 1335 | { |
|---|
| 1336 | exec => $HTML2TML, |
|---|
| 1337 | name => 'Item4588', |
|---|
| 1338 | tml => <<XYZ, |
|---|
| 1339 | A <i> *here* </i>A B <b> _here_ </b>B C __here__ C D <b> <i>here</i></b>D E <b><i>here</i></b>E F <i> <b>here</b></i>F |
|---|
| 1340 | XYZ |
|---|
| 1341 | |
|---|
| 1342 | # This was: |
|---|
| 1343 | # A __here__ A B __here__ B C __here__ C D __here__ D E __here__ E F __here__ F |
|---|
| 1344 | # before the fix for Item5961, but that's clearly wrong; the spaces should |
|---|
| 1345 | # break the emphasis. |
|---|
| 1346 | html => <<XWYZ, |
|---|
| 1347 | A <i><b>here</b> </i>A |
|---|
| 1348 | B <b><i>here</i> </b>B |
|---|
| 1349 | C <b><i>here</i></b> C |
|---|
| 1350 | D <b> <i>here</i></b>D |
|---|
| 1351 | E <b><i>here</i></b>E |
|---|
| 1352 | F <i> <b>here</b></i>F |
|---|
| 1353 | XWYZ |
|---|
| 1354 | final_tml => <<ZYX, |
|---|
| 1355 | ZYX |
|---|
| 1356 | }, |
|---|
| 1357 | { |
|---|
| 1358 | exec => $ROUNDTRIP, |
|---|
| 1359 | name => "Item4615", |
|---|
| 1360 | tml => 'ABC<br /> _DEF_', |
|---|
| 1361 | html => 'ABC<br /><i>DEF</i>', |
|---|
| 1362 | }, |
|---|
| 1363 | { |
|---|
| 1364 | exec => $TML2HTML | $HTML2TML, |
|---|
| 1365 | name => 'Item4700', |
|---|
| 1366 | tml => <<EXPT, |
|---|
| 1367 | | ex | per | iment | |
|---|
| 1368 | | exper | iment || |
|---|
| 1369 | | expe || riment | |
|---|
| 1370 | || exper | iment | |
|---|
| 1371 | EXPT |
|---|
| 1372 | finaltml => <<EXPT, |
|---|
| 1373 | | ex | per | iment | |
|---|
| 1374 | | exper | iment || |
|---|
| 1375 | | expe || riment | |
|---|
| 1376 | | | exper | iment | |
|---|
| 1377 | EXPT |
|---|
| 1378 | html => <<HEXPT, |
|---|
| 1379 | <table cellspacing="1" cellpadding="0" border="1"> |
|---|
| 1380 | <tr><td>ex</td><td>per</td><td>iment</td></tr> |
|---|
| 1381 | <tr><td>exper</td><td colspan="2">iment</td></tr> |
|---|
| 1382 | <tr><td colspan="2">expe</td><td>riment</td></tr> |
|---|
| 1383 | <tr><td></td><td>exper</td><td>iment</td></tr> |
|---|
| 1384 | </table> |
|---|
| 1385 | HEXPT |
|---|
| 1386 | }, |
|---|
| 1387 | { |
|---|
| 1388 | exec => $ROUNDTRIP, |
|---|
| 1389 | name => 'Item4700_2', |
|---|
| 1390 | tml => <<EXPT, |
|---|
| 1391 | | ex | per | iment | |
|---|
| 1392 | | exper | iment || |
|---|
| 1393 | | expe || riment | |
|---|
| 1394 | | | exper | iment | |
|---|
| 1395 | EXPT |
|---|
| 1396 | html => <<HEXPT, |
|---|
| 1397 | <table cellspacing="1" cellpadding="0" border="1"> |
|---|
| 1398 | <tr><td>ex</td><td>per</td><td>iment</td></tr> |
|---|
| 1399 | <tr><td>exper</td><td colspan="2">iment</td></tr> |
|---|
| 1400 | <tr><td colspan="2">expe</td><td>riment</td></tr> |
|---|
| 1401 | <tr><td></td><td>exper</td><td>iment</td></tr> |
|---|
| 1402 | </table> |
|---|
| 1403 | HEXPT |
|---|
| 1404 | }, |
|---|
| 1405 | { |
|---|
| 1406 | exec => $HTML2TML | $ROUNDTRIP, |
|---|
| 1407 | name => 'collapse', |
|---|
| 1408 | html => <<COLLAPSE, |
|---|
| 1409 | blah<pre class="TMLverbatim">flub</pre> <pre class="TMLverbatim">wheep</pre> <pre class="TMLverbatim">spit</pre>blah |
|---|
| 1410 | COLLAPSE |
|---|
| 1411 | tml => <<ESPALLOC, |
|---|
| 1412 | blah<verbatim>flub |
|---|
| 1413 | wheep |
|---|
| 1414 | spit</verbatim>blah |
|---|
| 1415 | ESPALLOC |
|---|
| 1416 | }, |
|---|
| 1417 | { |
|---|
| 1418 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 1419 | name => 'Item4705_A', |
|---|
| 1420 | tml => <<SPACED, |
|---|
| 1421 | A |
|---|
| 1422 | |
|---|
| 1423 | <literal><b>B</b> </literal> |
|---|
| 1424 | |
|---|
| 1425 | C |
|---|
| 1426 | SPACED |
|---|
| 1427 | html => <<DECAPS, |
|---|
| 1428 | <p> |
|---|
| 1429 | A |
|---|
| 1430 | </p> |
|---|
| 1431 | <p> |
|---|
| 1432 | <div class="WYSIWYG_LITERAL"><b>B</b> </div> |
|---|
| 1433 | </p> |
|---|
| 1434 | <p> |
|---|
| 1435 | C |
|---|
| 1436 | </p> |
|---|
| 1437 | DECAPS |
|---|
| 1438 | }, |
|---|
| 1439 | { |
|---|
| 1440 | exec => $TML2HTML | $ROUNDTRIP | $HTML2TML, |
|---|
| 1441 | name => 'sticky', |
|---|
| 1442 | tml => <<GLUED, |
|---|
| 1443 | <sticky><font color="blue"> *|B|* </font></sticky> |
|---|
| 1444 | GLUED |
|---|
| 1445 | html => '<p> |
|---|
| 1446 | <div class="WYSIWYG_STICKY"><font color="blue"> *|B|* </font></div> |
|---|
| 1447 | </p> |
|---|
| 1448 | ' |
|---|
| 1449 | }, |
|---|
| 1450 | { |
|---|
| 1451 | exec => $TML2HTML, |
|---|
| 1452 | name => 'Item4705_B', |
|---|
| 1453 | tml => <<SPACED, |
|---|
| 1454 | A |
|---|
| 1455 | |
|---|
| 1456 | <verbatim>B</verbatim> |
|---|
| 1457 | |
|---|
| 1458 | C |
|---|
| 1459 | SPACED |
|---|
| 1460 | html => <<DECAPS, |
|---|
| 1461 | <p> |
|---|
| 1462 | A |
|---|
| 1463 | </p> |
|---|
| 1464 | <p> |
|---|
| 1465 | <pre class="TMLverbatim">B</pre> |
|---|
| 1466 | </p> |
|---|
| 1467 | <p> |
|---|
| 1468 | C |
|---|
| 1469 | </p> |
|---|
| 1470 | DECAPS |
|---|
| 1471 | }, |
|---|
| 1472 | { |
|---|
| 1473 | exec => $TML2HTML, |
|---|
| 1474 | name => 'Item4763', |
|---|
| 1475 | tml => <<SPACED, |
|---|
| 1476 | 1 One item |
|---|
| 1477 | spanning several lines |
|---|
| 1478 | 1 And another item |
|---|
| 1479 | with one space |
|---|
| 1480 | No more |
|---|
| 1481 | SPACED |
|---|
| 1482 | html => <<DECAPS, |
|---|
| 1483 | <ol> |
|---|
| 1484 | <li> One item spanning several lines |
|---|
| 1485 | |
|---|
| 1486 | </li> <li> And another item with one space |
|---|
| 1487 | </li></ol> |
|---|
| 1488 | No more |
|---|
| 1489 | DECAPS |
|---|
| 1490 | }, |
|---|
| 1491 | { |
|---|
| 1492 | exec => $ROUNDTRIP, |
|---|
| 1493 | name => 'Item4789', |
|---|
| 1494 | tml => "%EDITTABLE{}%\n| 1 | 2 |\n| 3 | 4 |", |
|---|
| 1495 | }, |
|---|
| 1496 | { |
|---|
| 1497 | exec => $ROUNDTRIP, |
|---|
| 1498 | name => 'ProtectAndSurvive', |
|---|
| 1499 | tml => |
|---|
| 1500 | '<ul type="compact">Fred</ul><h1 align="right">HAH</h1><ol onclick="burp">Joe</ol>', |
|---|
| 1501 | }, |
|---|
| 1502 | { |
|---|
| 1503 | name => 'Item4855', |
|---|
| 1504 | exec => $TML2HTML, |
|---|
| 1505 | tml => <<HERE, |
|---|
| 1506 | | [[LegacyTopic1]] | Main.SomeGuy | |
|---|
| 1507 | %TABLESEP% |
|---|
| 1508 | %SEARCH{"legacy" nonoise="on" format="| [[\$topic]] | [[\$wikiname]] |"}% |
|---|
| 1509 | HERE |
|---|
| 1510 | html => <<THERE, |
|---|
| 1511 | <table cellspacing="1" cellpadding="0" border="1"> |
|---|
| 1512 | <tr><td><span class="WYSIWYG_LINK">[[LegacyTopic1]]</span></td><td>Main.SomeGuy</td></tr> |
|---|
| 1513 | </table> |
|---|
| 1514 | <span class="WYSIWYG_PROTECTED"><br />%TABLESEP%</span> |
|---|
| 1515 | <span class="WYSIWYG_PROTECTED"><br />%SEARCH{"legacy" nonoise="on" format="| [[\$topic]] | [[\$wikiname]] |"}%</span> |
|---|
| 1516 | THERE |
|---|
| 1517 | }, |
|---|
| 1518 | { |
|---|
| 1519 | name => 'Item4871', |
|---|
| 1520 | exec => $TML2HTML, |
|---|
| 1521 | tml => <<'BLAH', |
|---|
| 1522 | Blah |
|---|
| 1523 | <a href="%SCRIPTURLPATH{"edit"}%/%WEB%/%TOPIC%?t=%GM%NOP%TIME{"$epoch"}%">edit</a> |
|---|
| 1524 | Blah |
|---|
| 1525 | BLAH |
|---|
| 1526 | html => <<'BLAH', |
|---|
| 1527 | <p> |
|---|
| 1528 | Blah |
|---|
| 1529 | <span class="WYSIWYG_PROTECTED"><a href="%SCRIPTURLPATH{"edit"}%/%WEB%/%TOPIC%?t=%GM%NOP%TIME{"$epoch"}%"></span>edit<span |
|---|
| 1530 | class="WYSIWYG_PROTECTED"></a></span> |
|---|
| 1531 | Blah |
|---|
| 1532 | </p> |
|---|
| 1533 | BLAH |
|---|
| 1534 | }, |
|---|
| 1535 | { |
|---|
| 1536 | name => 'Item4903', |
|---|
| 1537 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 1538 | tml => <<'BLAH', |
|---|
| 1539 | %IF{"X!=Y" then="z"}% |
|---|
| 1540 | BLAH |
|---|
| 1541 | html => <<'BLAH', |
|---|
| 1542 | <p> |
|---|
| 1543 | <span class="WYSIWYG_PROTECTED"> |
|---|
| 1544 | %IF{"X!=Y" then="z"}% |
|---|
| 1545 | </span> |
|---|
| 1546 | </p> |
|---|
| 1547 | BLAH |
|---|
| 1548 | }, |
|---|
| 1549 | { |
|---|
| 1550 | name => "Confused", |
|---|
| 1551 | exec => $HTML2TML, |
|---|
| 1552 | html => 'the <tt><tt>co</tt>mple<code>te</code></tt> table', |
|---|
| 1553 | tml => 'the =complete= table', |
|---|
| 1554 | }, |
|---|
| 1555 | { |
|---|
| 1556 | name => 'fontconv', |
|---|
| 1557 | exec => $HTML2TML, |
|---|
| 1558 | html => <<HERE, |
|---|
| 1559 | <font color="red" class="WYSIWYG_COLOR">red</font> |
|---|
| 1560 | <font style="color:green">green</font> |
|---|
| 1561 | <font style="border:1;color:blue">blue</font> |
|---|
| 1562 | <font class="WYSIWYG_COLOR" style="border:1;color:yellow">yellow</font> |
|---|
| 1563 | <font color="brown">brown</font> |
|---|
| 1564 | HERE |
|---|
| 1565 | tml => <<HERE, |
|---|
| 1566 | %RED%red%ENDCOLOR% %GREEN%green%ENDCOLOR% <font style="border:1;color:blue">blue</font> %YELLOW%yellow%ENDCOLOR% %BROWN%brown%ENDCOLOR% |
|---|
| 1567 | HERE |
|---|
| 1568 | }, |
|---|
| 1569 | { |
|---|
| 1570 | name => 'Item4974', |
|---|
| 1571 | exec => $HTML2TML, |
|---|
| 1572 | html => '<pre class="TMLverbatim">U<br></pre><p>L</p>', |
|---|
| 1573 | tml => <<HERE, |
|---|
| 1574 | <verbatim>U |
|---|
| 1575 | </verbatim> |
|---|
| 1576 | L |
|---|
| 1577 | HERE |
|---|
| 1578 | }, |
|---|
| 1579 | { |
|---|
| 1580 | name => 'Item4969', |
|---|
| 1581 | exec => $HTML2TML, |
|---|
| 1582 | html => <<HERE, |
|---|
| 1583 | <table cellspacing="1" cellpadding="0" border="1"> |
|---|
| 1584 | <tr><td>table element with a <hr /> horizontal rule</td></tr> |
|---|
| 1585 | </table> |
|---|
| 1586 | Mad Fish |
|---|
| 1587 | HERE |
|---|
| 1588 | tml => '| table element with a <hr /> horizontal rule | |
|---|
| 1589 | Mad Fish', |
|---|
| 1590 | }, |
|---|
| 1591 | { |
|---|
| 1592 | name => 'Item5076', |
|---|
| 1593 | exec => $HTML2TML, |
|---|
| 1594 | html => <<HERE, |
|---|
| 1595 | <table border="0"><tbody><tr><td><h2>Argh</h2><ul><li>Ergh </li></ul></td><td> </td></tr><tr><td> </td><td> </td></tr></tbody></table> |
|---|
| 1596 | HERE |
|---|
| 1597 | tml => '<table border="0"><tbody><tr><td> |
|---|
| 1598 | ---++ Argh |
|---|
| 1599 | * Ergh |
|---|
| 1600 | </td><td> </td></tr><tr><td> </td><td> </td></tr></tbody></table>', |
|---|
| 1601 | }, |
|---|
| 1602 | { |
|---|
| 1603 | name => 'Item5132', |
|---|
| 1604 | exec => $TML2HTML, |
|---|
| 1605 | html => <<HERE, |
|---|
| 1606 | <h1 class="TML"> Title<img src="art1.jpg"> </img> </h1> |
|---|
| 1607 | Peace in earth, and goodwill to all worms |
|---|
| 1608 | HERE |
|---|
| 1609 | tml => <<HERE, |
|---|
| 1610 | ---+ Title<img src="art1.jpg"></img> |
|---|
| 1611 | Peace in earth, and goodwill to all worms |
|---|
| 1612 | HERE |
|---|
| 1613 | }, |
|---|
| 1614 | { |
|---|
| 1615 | name => 'Item5179', |
|---|
| 1616 | exec => $TML2HTML | $HTML2TML, |
|---|
| 1617 | tml => <<HERE, |
|---|
| 1618 | <smeg> |
|---|
| 1619 | <verbatim> |
|---|
| 1620 | <img src="ball&co<ck>s">&><" |
|---|
| 1621 | </verbatim> |
|---|
| 1622 | &><" |
|---|
| 1623 | HERE |
|---|
| 1624 | html => <<HERE, |
|---|
| 1625 | <p> |
|---|
| 1626 | <span class="WYSIWYG_PROTECTED"><smeg></span> |
|---|
| 1627 | <pre class="TMLverbatim"><br /><img src="ball&co<ck>s">&><"<br /></pre> |
|---|
| 1628 | &><" |
|---|
| 1629 | </p> |
|---|
| 1630 | HERE |
|---|
| 1631 | finaltml => <<HERE, |
|---|
| 1632 | <smeg> <verbatim> |
|---|
| 1633 | <img src="ball&co<ck>s">&><" |
|---|
| 1634 | </verbatim> &><" |
|---|
| 1635 | HERE |
|---|
| 1636 | }, |
|---|
| 1637 | { |
|---|
| 1638 | name => "Item5337", |
|---|
| 1639 | exec => $TML2HTML | $ROUNDTRIP, |
|---|
| 1640 | tml => <<HERE, |
|---|
| 1641 | <pre> |
|---|
| 1642 | hello |
|---|
| 1643 | there |
|---|
| 1644 | </pre> |
|---|
| 1645 | HERE |
|---|
| 1646 | finaltml => <<HERE, |
|---|
| 1647 | <pre> |
|---|
| 1648 | hello |
|---|
| 1649 | there |
|---|
| 1650 | </pre> |
|---|
| 1651 | HERE |
|---|
| 1652 | html => <<HERE, |
|---|
| 1653 | <p> |
|---|
| 1654 | <pre> |
|---|
| 1655 | hello |
|---|
| 1656 | there |
|---|
| 1657 | </pre> |
|---|
| 1658 | </p> |
|---|
| 1659 | HERE |
|---|
| 1660 | }, |
|---|
| 1661 | { |
|---|
| 1662 | name => 'Item5664', |
|---|
| 1663 | exec => $HTML2TML | $ROUNDTRIP, |
|---|
| 1664 | html => '<ul> <li> A </li> </ul> B', |
|---|
| 1665 | tml => <<HERE, |
|---|
| 1666 | * A |
|---|
| 1667 | B |
|---|
| 1668 | HERE |
|---|
| 1669 | }, |
|---|
| 1670 | { |
|---|
| 1671 | name => "Item5961", |
|---|
| 1672 | exec => $HTML2TML | $ROUNDTRIP, |
|---|
| 1673 | html => 'o<strong>n</strong>e', |
|---|
| 1674 | html => |
|---|
| 1675 | ' <strong>zero</strong> <strong>on</strong>e t<strong>w</strong>o t<strong>re</strong>', |
|---|
| 1676 | tml => |
|---|
| 1677 | '*zero* <strong>on</strong>e t<strong>w</strong>o t<strong>re</strong>', |
|---|
| 1678 | }, |
|---|
| 1679 | { |
|---|
| 1680 | name => "Item6089", |
|---|
| 1681 | exec => $TML2HTML, |
|---|
| 1682 | tml => <<'ZIS', |
|---|
| 1683 | <verbatim> |
|---|
| 1684 | line1\ |
|---|
| 1685 | line2 |
|---|
| 1686 | </verbatim> |
|---|
| 1687 | ZIS |
|---|
| 1688 | html => <<'ZAT', |
|---|
| 1689 | <p> |
|---|
| 1690 | <pre class="TMLverbatim"><br />line1\<br />line2<br /></pre> |
|---|
| 1691 | </p> |
|---|
| 1692 | ZAT |
|---|
| 1693 | }, |
|---|
| 1694 | ]; |
|---|
| 1695 | |
|---|
| 1696 | sub gen_compare_tests { |
|---|
| 1697 | my %picked = map { $_ => 1 } @_; |
|---|
| 1698 | for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { |
|---|
| 1699 | my $datum = $data->[$i]; |
|---|
| 1700 | if ( scalar(@_) ) { |
|---|
| 1701 | next unless ( $picked{ $datum->{name} } ); |
|---|
| 1702 | } |
|---|
| 1703 | if ( ( $mask & $datum->{exec} ) & $TML2HTML ) { |
|---|
| 1704 | my $fn = 'TranslatorTests::testTML2HTML_' . $datum->{name}; |
|---|
| 1705 | no strict 'refs'; |
|---|
| 1706 | *$fn = sub { my $this = shift; $this->compareTML_HTML($datum) }; |
|---|
| 1707 | use strict 'refs'; |
|---|
| 1708 | } |
|---|
| 1709 | if ( ( $mask & $datum->{exec} ) & $HTML2TML ) { |
|---|
| 1710 | my $fn = 'TranslatorTests::testHTML2TML_' . $datum->{name}; |
|---|
| 1711 | no strict 'refs'; |
|---|
| 1712 | *$fn = sub { my $this = shift; $this->compareHTML_TML($datum) }; |
|---|
| 1713 | use strict 'refs'; |
|---|
| 1714 | } |
|---|
| 1715 | if ( ( $mask & $datum->{exec} ) & $ROUNDTRIP ) { |
|---|
| 1716 | my $fn = 'TranslatorTests::testROUNDTRIP_' . $datum->{name}; |
|---|
| 1717 | no strict 'refs'; |
|---|
| 1718 | *$fn = sub { my $this = shift; $this->compareRoundTrip($datum) }; |
|---|
| 1719 | use strict 'refs'; |
|---|
| 1720 | } |
|---|
| 1721 | } |
|---|
| 1722 | } |
|---|
| 1723 | |
|---|
| 1724 | # Run from BEGIN |
|---|
| 1725 | sub gen_file_tests { |
|---|
| 1726 | foreach my $d (@INC) { |
|---|
| 1727 | if ( -d "$d/test_html" && $d =~ /WysiwygPlugin/ ) { |
|---|
| 1728 | opendir( D, "$d/test_html" ) or die; |
|---|
| 1729 | foreach my $file ( grep { /^.*\.html$/i } readdir D ) { |
|---|
| 1730 | $file =~ s/\.html$//; |
|---|
| 1731 | my $test = { name => $file }; |
|---|
| 1732 | open( F, "<$d/test_html/$file.html" ); |
|---|
| 1733 | undef $/; |
|---|
| 1734 | $test->{html} = <F>; |
|---|
| 1735 | close(F); |
|---|
| 1736 | next unless -e "$d/result_tml/$file.txt"; |
|---|
| 1737 | open( F, "<$d/result_tml/$file.txt" ); |
|---|
| 1738 | undef $/; |
|---|
| 1739 | $test->{finaltml} = <F>; |
|---|
| 1740 | close(F); |
|---|
| 1741 | my $fn = 'TranslatorTests::test_HTML2TML_FILE_' . $test->{name}; |
|---|
| 1742 | no strict 'refs'; |
|---|
| 1743 | *$fn = sub { shift->compareHTML_TML($test) }; |
|---|
| 1744 | use strict 'refs'; |
|---|
| 1745 | } |
|---|
| 1746 | last; |
|---|
| 1747 | } |
|---|
| 1748 | } |
|---|
| 1749 | } |
|---|
| 1750 | |
|---|
| 1751 | sub set_up { |
|---|
| 1752 | my $this = shift; |
|---|
| 1753 | $this->SUPER::set_up(@_); |
|---|
| 1754 | $Foswiki::cfg{Plugins}{WysiwygPlugin}{Enabled} = 1; |
|---|
| 1755 | |
|---|
| 1756 | my $query; |
|---|
| 1757 | eval { |
|---|
| 1758 | require Unit::Request; |
|---|
| 1759 | require Unit::Response; |
|---|
| 1760 | $query = new Unit::Request(""); |
|---|
| 1761 | }; |
|---|
| 1762 | if ($@) { |
|---|
| 1763 | $query = new CGI(""); |
|---|
| 1764 | } |
|---|
| 1765 | $query->path_info("/Current/TestTopic"); |
|---|
| 1766 | $this->{session} = new Foswiki( undef, $query ); |
|---|
| 1767 | $Foswiki::Plugins::SESSION = $this->{session}; |
|---|
| 1768 | } |
|---|
| 1769 | |
|---|
| 1770 | sub normaliseEntities { |
|---|
| 1771 | my $text = shift; |
|---|
| 1772 | |
|---|
| 1773 | # Convert text entities to &# representation |
|---|
| 1774 | $text =~ s/(&\w+;)/'&#'.ord(HTML::Entities::decode_entities($1)).';'/ge; |
|---|
| 1775 | return $text; |
|---|
| 1776 | } |
|---|
| 1777 | |
|---|
| 1778 | sub compareTML_HTML { |
|---|
| 1779 | my ( $this, $args ) = @_; |
|---|
| 1780 | |
|---|
| 1781 | my $page = |
|---|
| 1782 | $this->{session}->getScriptUrl( 1, 'view', 'Current', 'TestTopic' ); |
|---|
| 1783 | $page =~ s/\/Current\/TestTopic.*$//; |
|---|
| 1784 | my $html = $args->{html} || ''; |
|---|
| 1785 | $html =~ s/%!page!%/$page/g; |
|---|
| 1786 | my $finaltml = $args->{finaltml} || ''; |
|---|
| 1787 | $finaltml =~ s/%!page!%/$page/g; |
|---|
| 1788 | my $tml = $args->{tml} || ''; |
|---|
| 1789 | $tml =~ s/%!page!%/$page/g; |
|---|
| 1790 | |
|---|
| 1791 | my $txer = new Foswiki::Plugins::WysiwygPlugin::TML2HTML(); |
|---|
| 1792 | my $tx = $txer->convert( |
|---|
| 1793 | $tml, |
|---|
| 1794 | { |
|---|
| 1795 | web => 'Current', |
|---|
| 1796 | topic => 'TestTopic', |
|---|
| 1797 | getViewUrl => \&Foswiki::Plugins::WysiwygPlugin::getViewUrl, |
|---|
| 1798 | expandVarsInURL => |
|---|
| 1799 | \&Foswiki::Plugins::WysiwygPlugin::expandVarsInURL, |
|---|
| 1800 | } |
|---|
| 1801 | ); |
|---|
| 1802 | |
|---|
| 1803 | $this->assert_html_equals( $html, $tx ); |
|---|
| 1804 | } |
|---|
| 1805 | |
|---|
| 1806 | sub compareRoundTrip { |
|---|
| 1807 | my ( $this, $args ) = @_; |
|---|
| 1808 | my $page = |
|---|
| 1809 | $this->{session}->getScriptUrl( 1, 'view', 'Current', 'TestTopic' ); |
|---|
| 1810 | $page =~ s/\/Current\/TestTopic.*$//; |
|---|
| 1811 | |
|---|
| 1812 | my $tml = $args->{tml} || ''; |
|---|
| 1813 | $tml =~ s/%!page!%/$page/g; |
|---|
| 1814 | |
|---|
| 1815 | my $txer = new Foswiki::Plugins::WysiwygPlugin::TML2HTML(); |
|---|
| 1816 | my $html = $txer->convert( |
|---|
| 1817 | $tml, |
|---|
| 1818 | { |
|---|
| 1819 | web => 'Current', |
|---|
| 1820 | topic => 'TestTopic', |
|---|
| 1821 | getViewUrl => \&Foswiki::Plugins::WysiwygPlugin::getViewUrl, |
|---|
| 1822 | expandVarsInURL => |
|---|
| 1823 | \&Foswiki::Plugins::WysiwygPlugin::expandVarsInURL, |
|---|
| 1824 | } |
|---|
| 1825 | ); |
|---|
| 1826 | |
|---|
| 1827 | $txer = new Foswiki::Plugins::WysiwygPlugin::HTML2TML(); |
|---|
| 1828 | my $tx = $txer->convert( |
|---|
| 1829 | $html, |
|---|
| 1830 | { |
|---|
| 1831 | web => 'Current', |
|---|
| 1832 | topic => 'TestTopic', |
|---|
| 1833 | convertImage => \&convertImage, |
|---|
| 1834 | rewriteURL => \&Foswiki::Plugins::WysiwygPlugin::postConvertURL, |
|---|
| 1835 | } |
|---|
| 1836 | ); |
|---|
| 1837 | my $finaltml = $args->{finaltml} || $tml; |
|---|
| 1838 | $finaltml =~ s/%!page!%/$page/g; |
|---|
| 1839 | $this->_assert_tml_equals( $finaltml, $tx, $args->{name} ); |
|---|
| 1840 | } |
|---|
| 1841 | |
|---|
| 1842 | sub compareHTML_TML { |
|---|
| 1843 | my ( $this, $args ) = @_; |
|---|
| 1844 | |
|---|
| 1845 | my $page = |
|---|
| 1846 | $this->{session}->getScriptUrl( 1, 'view', 'Current', 'TestTopic' ); |
|---|
| 1847 | $page =~ s/\/Current\/TestTopic.*$//; |
|---|
| 1848 | my $html = $args->{html} || ''; |
|---|
| 1849 | $html =~ s/%!page!%/$page/g; |
|---|
| 1850 | my $tml = $args->{tml} || ''; |
|---|
| 1851 | $tml =~ s/%!page!%/$page/g; |
|---|
| 1852 | my $finaltml = $args->{finaltml} || $tml; |
|---|
| 1853 | $finaltml =~ s/%!page!%/$page/g; |
|---|
| 1854 | |
|---|
| 1855 | my $txer = new Foswiki::Plugins::WysiwygPlugin::HTML2TML(); |
|---|
| 1856 | my $tx = $txer->convert( |
|---|
| 1857 | $html, |
|---|
| 1858 | { |
|---|
| 1859 | web => 'Current', |
|---|
| 1860 | topic => 'TestTopic', |
|---|
| 1861 | convertImage => \&convertImage, |
|---|
| 1862 | rewriteURL => \&Foswiki::Plugins::WysiwygPlugin::postConvertURL, |
|---|
| 1863 | } |
|---|
| 1864 | ); |
|---|
| 1865 | $this->_assert_tml_equals( $finaltml, $tx, $args->{name} ); |
|---|
| 1866 | } |
|---|
| 1867 | |
|---|
| 1868 | sub encode { |
|---|
| 1869 | my $s = shift; |
|---|
| 1870 | |
|---|
| 1871 | # used for debugging odd chars |
|---|
| 1872 | # $s =~ s/([\000-\037])/'#'.ord($1)/ge; |
|---|
| 1873 | return $s; |
|---|
| 1874 | } |
|---|
| 1875 | |
|---|
| 1876 | sub _assert_tml_equals { |
|---|
| 1877 | my ( $this, $expected, $actual, $name ) = @_; |
|---|
| 1878 | $expected ||= ''; |
|---|
| 1879 | $actual ||= ''; |
|---|
| 1880 | $actual =~ s/\n$//s; |
|---|
| 1881 | $expected =~ s/\n$//s; |
|---|
| 1882 | unless ( $expected eq $actual ) { |
|---|
| 1883 | my $expl = |
|---|
| 1884 | "==$name== Expected TML:\n" |
|---|
| 1885 | . encode($expected) |
|---|
| 1886 | . "\n==$name== Actual TML:\n" |
|---|
| 1887 | . encode($actual) |
|---|
| 1888 | . "\n==$name==\n"; |
|---|
| 1889 | my $i = 0; |
|---|
| 1890 | while ( $i < length($expected) && $i < length($actual) ) { |
|---|
| 1891 | my $e = substr( $expected, $i, 1 ); |
|---|
| 1892 | my $a = substr( $actual, $i, 1 ); |
|---|
| 1893 | if ( $a ne $e ) { |
|---|
| 1894 | $expl .= "<<==== HERE actual "; |
|---|
| 1895 | $expl .= ord($a) . " != expected " . ord($e) . "\n"; |
|---|
| 1896 | last; |
|---|
| 1897 | } |
|---|
| 1898 | $expl .= $a; |
|---|
| 1899 | $i++; |
|---|
| 1900 | } |
|---|
| 1901 | $this->assert( 0, $expl . "\n" ); |
|---|
| 1902 | } |
|---|
| 1903 | } |
|---|
| 1904 | |
|---|
| 1905 | sub convertImage { |
|---|
| 1906 | my $url = shift; |
|---|
| 1907 | |
|---|
| 1908 | if ( $url eq "test_image" ) { |
|---|
| 1909 | return '%TRANSLATEDIMAGE%'; |
|---|
| 1910 | } |
|---|
| 1911 | } |
|---|
| 1912 | |
|---|
| 1913 | gen_compare_tests(); |
|---|
| 1914 | |
|---|
| 1915 | #gen_file_tests(); |
|---|
| 1916 | |
|---|
| 1917 | 1; |
|---|