r101803 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101802‎ | r101803 | r101804 >
Date:13:55, 3 November 2011
Author:gwicke
Status:deferred
Tags:
Comment:
First combination of WikiDom serializers with existing parser in
tests/parser/parserTests.js.

* Removed var from es in es.js to allow node.js to access it as global. Only
alternative solution appears to be a node-specific 'exports' construct:
http://nodejs.org/docs/v0.3.1/api/modules.html
* Added es.Document.js and es.Document.Serializer.js in es/bases. Not sure if
this is the desired location.
* Changed es.extend to es.extendClass in the serializers
* Modified the first parser test to include the WikiDom modules and call the
new HTML serializer
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/bases/es.Document.Serializer.js (added) (history)
  • /trunk/extensions/VisualEditor/modules/es/bases/es.Document.js (added) (history)
  • /trunk/extensions/VisualEditor/modules/es/es.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/serializers/es.Document.HtmlSerializer.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/serializers/es.Document.JsonSerializer.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/serializers/es.Document.WikitextSerializer.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt (modified) (history)
  • /trunk/extensions/VisualEditor/tests/parser (added) (history)
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/expansionTest.js
@@ -0,0 +1,87 @@
 2+var pageDatabase = {
 3+ 'Boring': 'Just some text and [[a link]].',
 4+ 'Template:Parens': '({{{1}}})',
 5+ 'ParenCaller': '{{Parens|bizbax}}'
 6+}
 7+var domDatabase = {
 8+ 'Boring': {
 9+ type: 'root',
 10+ contents: [
 11+ 'Just some text and ',
 12+ {
 13+ type: 'link',
 14+ target: 'a link'
 15+ },
 16+ '.'
 17+ ]
 18+ },
 19+ 'Template:Parens': {
 20+ type: 'root',
 21+ contents: [
 22+ '(',
 23+ {
 24+ type: 'tplarg',
 25+ /*
 26+ contents: [
 27+ '1'
 28+ ]*/
 29+ name: '1'
 30+ },
 31+ ')'
 32+ ]
 33+ },
 34+ 'ParenCaller': {
 35+ type: 'root',
 36+ contents: [
 37+ {
 38+ type: 'template',
 39+ /*
 40+ contents: [
 41+ {
 42+ type: 'title',
 43+ contents: [
 44+ 'Parens'
 45+ ]
 46+ },
 47+ {
 48+ type: 'part',
 49+ contents: [
 50+ {
 51+ type: 'name',
 52+ index: 1
 53+ },
 54+ {
 55+ type: 'value',
 56+ contents: [
 57+ 'bizbax'
 58+ ]
 59+ }
 60+ ]
 61+ }
 62+ ]*/
 63+ name: 'Parens',
 64+ params: {
 65+ 1: 'bizbax'
 66+ }
 67+ }
 68+ ]
 69+ }
 70+};
 71+
 72+$(function() {
 73+ var env = new MWParserEnvironment({
 74+ 'pageCache': pageDatabase,
 75+ 'domCache': domDatabase
 76+ });
 77+ env.debug = true;
 78+ var frame = new PPFrame(env);
 79+ //var victim = 'Boring';
 80+ var victim = 'ParenCaller';
 81+ frame.expand(domDatabase[victim], 0, function(node, err) {
 82+ if (err) {
 83+ console.log('error', err);
 84+ } else {
 85+ console.log(node);
 86+ }
 87+ });
 88+})
Property changes on: trunk/extensions/VisualEditor/tests/parser/expansionTest.js
___________________________________________________________________
Added: svn:eol-style
189 + native
Index: trunk/extensions/VisualEditor/tests/parser/wikia-rte-roundtrip-tests.xml
@@ -0,0 +1,1303 @@
 2+<mediawiki>
 3+<page><id>1</id><title>Wikia RTE round-trip test 1</title><revision><id>1</id><text xml:space="preserve"></text></revision></page>
 4+<page><id>2</id><title>Wikia RTE round-trip test 2</title><revision><id>2</id><text xml:space="preserve">
 5+1a</text></revision></page>
 6+<page><id>3</id><title>Wikia RTE round-trip test 3</title><revision><id>3</id><text xml:space="preserve">
 7+
 8+1b</text></revision></page>
 9+<page><id>4</id><title>Wikia RTE round-trip test 4</title><revision><id>4</id><text xml:space="preserve">
 10+
 11+
 12+1c</text></revision></page>
 13+<page><id>5</id><title>Wikia RTE round-trip test 5</title><revision><id>5</id><text xml:space="preserve">
 14+
 15+
 16+
 17+1d</text></revision></page>
 18+<page><id>6</id><title>Wikia RTE round-trip test 6</title><revision><id>6</id><text xml:space="preserve">
 19+
 20+
 21+
 22+
 23+1e</text></revision></page>
 24+<page><id>7</id><title>Wikia RTE round-trip test 7</title><revision><id>7</id><text xml:space="preserve">
 25+
 26+
 27+
 28+
 29+
 30+1f</text></revision></page>
 31+<page><id>8</id><title>Wikia RTE round-trip test 8</title><revision><id>8</id><text xml:space="preserve">
 32+
 33+
 34+
 35+
 36+
 37+
 38+1g</text></revision></page>
 39+<page><id>9</id><title>Wikia RTE round-trip test 9</title><revision><id>9</id><text xml:space="preserve">
 40+
 41+
 42+
 43+
 44+
 45+
 46+
 47+1h</text></revision></page>
 48+<page><id>10</id><title>Wikia RTE round-trip test 10</title><revision><id>10</id><text xml:space="preserve">
 49+
 50+
 51+
 52+
 53+
 54+
 55+
 56+
 57+1i</text></revision></page>
 58+<page><id>11</id><title>Wikia RTE round-trip test 11</title><revision><id>11</id><text xml:space="preserve">
 59+
 60+
 61+
 62+
 63+
 64+
 65+
 66+
 67+
 68+1j</text></revision></page>
 69+<page><id>12</id><title>Wikia RTE round-trip test 12</title><revision><id>12</id><text xml:space="preserve">1a</text></revision></page>
 70+<page><id>13</id><title>Wikia RTE round-trip test 13</title><revision><id>13</id><text xml:space="preserve">1
 71+b</text></revision></page>
 72+<page><id>14</id><title>Wikia RTE round-trip test 14</title><revision><id>14</id><text xml:space="preserve">1
 73+
 74+c</text></revision></page>
 75+<page><id>15</id><title>Wikia RTE round-trip test 15</title><revision><id>15</id><text xml:space="preserve">1
 76+
 77+
 78+d
 79+
 80+
 81+x</text></revision></page>
 82+<page><id>16</id><title>Wikia RTE round-trip test 16</title><revision><id>16</id><text xml:space="preserve">1
 83+
 84+
 85+
 86+e
 87+
 88+3</text></revision></page>
 89+<page><id>17</id><title>Wikia RTE round-trip test 17</title><revision><id>17</id><text xml:space="preserve">1
 90+
 91+
 92+
 93+
 94+f
 95+3</text></revision></page>
 96+<page><id>18</id><title>Wikia RTE round-trip test 18</title><revision><id>18</id><text xml:space="preserve">1
 97+
 98+
 99+
 100+
 101+
 102+g
 103+3</text></revision></page>
 104+<page><id>19</id><title>Wikia RTE round-trip test 19</title><revision><id>19</id><text xml:space="preserve">1
 105+
 106+
 107+
 108+
 109+
 110+
 111+h
 112+3</text></revision></page>
 113+<page><id>20</id><title>Wikia RTE round-trip test 20</title><revision><id>20</id><text xml:space="preserve">1
 114+
 115+
 116+
 117+
 118+
 119+
 120+
 121+i
 122+3</text></revision></page>
 123+<page><id>21</id><title>Wikia RTE round-trip test 21</title><revision><id>21</id><text xml:space="preserve">1
 124+
 125+
 126+
 127+
 128+
 129+
 130+
 131+
 132+j
 133+3</text></revision></page>
 134+<page><id>22</id><title>Wikia RTE round-trip test 22</title><revision><id>22</id><text xml:space="preserve">1
 135+
 136+
 137+
 138+
 139+
 140+
 141+
 142+
 143+
 144+k
 145+
 146+
 147+3</text></revision></page>
 148+<page><id>23</id><title>Wikia RTE round-trip test 23</title><revision><id>23</id><text xml:space="preserve">1
 149+
 150+
 151+
 152+
 153+
 154+
 155+
 156+
 157+
 158+
 159+
 160+
 161+
 162+
 163+l
 164+
 165+
 166+
 167+
 168+
 169+3</text></revision></page>
 170+<page><id>24</id><title>Wikia RTE round-trip test 24</title><revision><id>24</id><text xml:space="preserve">1
 171+
 172+
 173+
 174+
 175+
 176+
 177+m
 178+
 179+
 180+
 181+
 182+
 183+3
 184+
 185+
 186+
 187+4
 188+
 189+
 190+
 191+
 192+5
 193+6
 194+
 195+
 196+
 197+
 198+
 199+
 200+
 201+
 202+
 203+7
 204+8
 205+
 206+9</text></revision></page>
 207+<page><id>25</id><title>Wikia RTE round-trip test 25</title><revision><id>25</id><text xml:space="preserve">1
 208+a</text></revision></page>
 209+<page><id>26</id><title>Wikia RTE round-trip test 26</title><revision><id>26</id><text xml:space="preserve">1
 210+b</text></revision></page>
 211+<page><id>27</id><title>Wikia RTE round-trip test 27</title><revision><id>27</id><text xml:space="preserve">1
 212+c</text></revision></page>
 213+<page><id>28</id><title>Wikia RTE round-trip test 28</title><revision><id>28</id><text xml:space="preserve">1
 214+d</text></revision></page>
 215+<page><id>29</id><title>Wikia RTE round-trip test 29</title><revision><id>29</id><text xml:space="preserve">1 b
 216+3 4
 217+
 218+5 6
 219+
 220+
 221+y 8</text></revision></page>
 222+<page><id>30</id><title>Wikia RTE round-trip test 30</title><revision><id>30</id><text xml:space="preserve">#1
 223+#2
 224+#3</text></revision></page>
 225+<page><id>31</id><title>Wikia RTE round-trip test 31</title><revision><id>31</id><text xml:space="preserve">*1
 226+*2
 227+*3</text></revision></page>
 228+<page><id>32</id><title>Wikia RTE round-trip test 32</title><revision><id>32</id><text xml:space="preserve">#1
 229+##2
 230+##3
 231+###4</text></revision></page>
 232+<page><id>33</id><title>Wikia RTE round-trip test 33</title><revision><id>33</id><text xml:space="preserve">*1
 233+**2
 234+**3
 235+***4</text></revision></page>
 236+<page><id>34</id><title>Wikia RTE round-trip test 34</title><revision><id>34</id><text xml:space="preserve">#1
 237+#*2
 238+#**5
 239+#**3
 240+#4</text></revision></page>
 241+<page><id>35</id><title>Wikia RTE round-trip test 35</title><revision><id>35</id><text xml:space="preserve">#1
 242+##1
 243+##2
 244+###1
 245+###*1
 246+###*2
 247+###**345
 248+###**567
 249+###**#1
 250+###**#2
 251+###**##123123
 252+###**#3
 253+###**123
 254+###*3
 255+###2
 256+##3
 257+#2
 258+#3
 259+#4
 260+#5</text></revision></page>
 261+<page><id>36</id><title>Wikia RTE round-trip test 36</title><revision><id>36</id><text xml:space="preserve">
 262+#1
 263+*2
 264+
 265+#3
 266+
 267+
 268+*4
 269+
 270+*5
 271+#6</text></revision></page>
 272+<page><id>37</id><title>Wikia RTE round-trip test 37</title><revision><id>37</id><text xml:space="preserve">
 273+
 274+*1
 275+*2
 276+*3</text></revision></page>
 277+<page><id>38</id><title>Wikia RTE round-trip test 38</title><revision><id>38</id><text xml:space="preserve">
 278+
 279+
 280+*1
 281+*2
 282+*3</text></revision></page>
 283+<page><id>39</id><title>Wikia RTE round-trip test 39</title><revision><id>39</id><text xml:space="preserve">*1
 284+*2
 285+*a
 286+#a
 287+#b
 288+#c</text></revision></page>
 289+<page><id>40</id><title>Wikia RTE round-trip test 40</title><revision><id>40</id><text xml:space="preserve">*1
 290+*2
 291+*b
 292+
 293+#a
 294+#b
 295+#c</text></revision></page>
 296+<page><id>41</id><title>Wikia RTE round-trip test 41</title><revision><id>41</id><text xml:space="preserve">*1
 297+*2
 298+*c
 299+
 300+
 301+#a
 302+#b
 303+#c</text></revision></page>
 304+<page><id>42</id><title>Wikia RTE round-trip test 42</title><revision><id>42</id><text xml:space="preserve">*1
 305+*2
 306+*d
 307+
 308+
 309+
 310+#a
 311+#b
 312+#c</text></revision></page>
 313+<page><id>43</id><title>Wikia RTE round-trip test 43</title><revision><id>43</id><text xml:space="preserve">*1
 314+*2
 315+*e
 316+
 317+
 318+
 319+
 320+#a
 321+#b
 322+#c</text></revision></page>
 323+<page><id>44</id><title>Wikia RTE round-trip test 44</title><revision><id>44</id><text xml:space="preserve">
 324+
 325+*1
 326+*2</text></revision></page>
 327+<page><id>45</id><title>Wikia RTE round-trip test 45</title><revision><id>45</id><text xml:space="preserve">
 328+
 329+
 330+*1
 331+
 332+*2</text></revision></page>
 333+<page><id>46</id><title>Wikia RTE round-trip test 46</title><revision><id>46</id><text xml:space="preserve">
 334+
 335+
 336+
 337+*1
 338+
 339+
 340+*2</text></revision></page>
 341+<page><id>47</id><title>Wikia RTE round-trip test 47</title><revision><id>47</id><text xml:space="preserve">*1
 342+
 343+
 344+
 345+*2</text></revision></page>
 346+<page><id>48</id><title>Wikia RTE round-trip test 48</title><revision><id>48</id><text xml:space="preserve">
 347+
 348+
 349+
 350+
 351+
 352+
 353+
 354+
 355+*1
 356+
 357+
 358+
 359+
 360+*2</text></revision></page>
 361+<page><id>49</id><title>Wikia RTE round-trip test 49</title><revision><id>49</id><text xml:space="preserve">#1
 362+#a</text></revision></page>
 363+<page><id>50</id><title>Wikia RTE round-trip test 50</title><revision><id>50</id><text xml:space="preserve">#1
 364+
 365+#b</text></revision></page>
 366+<page><id>51</id><title>Wikia RTE round-trip test 51</title><revision><id>51</id><text xml:space="preserve">#1
 367+
 368+
 369+#c</text></revision></page>
 370+<page><id>52</id><title>Wikia RTE round-trip test 52</title><revision><id>52</id><text xml:space="preserve">#1
 371+
 372+
 373+
 374+#d</text></revision></page>
 375+<page><id>53</id><title>Wikia RTE round-trip test 53</title><revision><id>53</id><text xml:space="preserve">#1
 376+
 377+
 378+
 379+
 380+#e</text></revision></page>
 381+<page><id>54</id><title>Wikia RTE round-trip test 54</title><revision><id>54</id><text xml:space="preserve">1
 382+*2
 383+*a
 384+4</text></revision></page>
 385+<page><id>55</id><title>Wikia RTE round-trip test 55</title><revision><id>55</id><text xml:space="preserve">1
 386+
 387+*2
 388+*b
 389+
 390+4</text></revision></page>
 391+<page><id>56</id><title>Wikia RTE round-trip test 56</title><revision><id>56</id><text xml:space="preserve">
 392+1
 393+
 394+*2
 395+
 396+
 397+*c
 398+
 399+4</text></revision></page>
 400+<page><id>57</id><title>Wikia RTE round-trip test 57</title><revision><id>57</id><text xml:space="preserve">1
 401+#2
 402+#3
 403+a</text></revision></page>
 404+<page><id>58</id><title>Wikia RTE round-trip test 58</title><revision><id>58</id><text xml:space="preserve">1
 405+
 406+#2
 407+#3
 408+
 409+b</text></revision></page>
 410+<page><id>59</id><title>Wikia RTE round-trip test 59</title><revision><id>59</id><text xml:space="preserve">
 411+1
 412+
 413+#2
 414+
 415+
 416+#3
 417+
 418+c</text></revision></page>
 419+<page><id>60</id><title>Wikia RTE round-trip test 60</title><revision><id>60</id><text xml:space="preserve">
 420+1
 421+
 422+#2
 423+
 424+
 425+*5
 426+
 427+
 428+#3
 429+
 430+d</text></revision></page>
 431+<page><id>61</id><title>Wikia RTE round-trip test 61</title><revision><id>61</id><text xml:space="preserve">=1=
 432+= 1=
 433+=1 =
 434+= 1 =
 435+= 1 =
 436+==1==
 437+== 1==
 438+==1 ==
 439+== 1 ==
 440+== 1 ==
 441+===1===
 442+=== 1===
 443+===1 ===
 444+=== 1 ===
 445+=== 1 ===
 446+====1====
 447+==== 1====
 448+====1 ====
 449+==== 1 ====
 450+==== 1 ====
 451+=====1=====
 452+===== 1=====
 453+=====1 =====
 454+===== 1 =====
 455+===== 1 =====
 456+======1======
 457+====== 1======
 458+======1 ======
 459+====== 1 ======
 460+====== 1 ======</text></revision></page>
 461+<page><id>62</id><title>Wikia RTE round-trip test 62</title><revision><id>62</id><text xml:space="preserve">* 1a
 462+* 2
 463+* 3
 464+* 10
 465+* 11
 466+* 12
 467+* 4
 468+* 5
 469+* 6
 470+* 7
 471+* 8
 472+* 9</text></revision></page>
 473+<page><id>63</id><title>Wikia RTE round-trip test 63</title><revision><id>63</id><text xml:space="preserve"># 1b
 474+# 2
 475+# 3
 476+# 10
 477+# 11
 478+# 12
 479+# 4
 480+# 5
 481+# 6
 482+# 7
 483+# 8
 484+# 9</text></revision></page>
 485+<page><id>64</id><title>Wikia RTE round-trip test 64</title><revision><id>64</id><text xml:space="preserve">
 486+=1a=</text></revision></page>
 487+<page><id>65</id><title>Wikia RTE round-trip test 65</title><revision><id>65</id><text xml:space="preserve">
 488+
 489+=1b=</text></revision></page>
 490+<page><id>66</id><title>Wikia RTE round-trip test 66</title><revision><id>66</id><text xml:space="preserve">
 491+
 492+
 493+=1c=</text></revision></page>
 494+<page><id>67</id><title>Wikia RTE round-trip test 67</title><revision><id>67</id><text xml:space="preserve">
 495+
 496+
 497+
 498+=1d=</text></revision></page>
 499+<page><id>68</id><title>Wikia RTE round-trip test 68</title><revision><id>68</id><text xml:space="preserve">
 500+
 501+
 502+
 503+
 504+=1e=</text></revision></page>
 505+<page><id>69</id><title>Wikia RTE round-trip test 69</title><revision><id>69</id><text xml:space="preserve">
 506+
 507+
 508+
 509+
 510+
 511+=1f=</text></revision></page>
 512+<page><id>70</id><title>Wikia RTE round-trip test 70</title><revision><id>70</id><text xml:space="preserve">
 513+
 514+
 515+
 516+
 517+
 518+
 519+=1g=</text></revision></page>
 520+<page><id>71</id><title>Wikia RTE round-trip test 71</title><revision><id>71</id><text xml:space="preserve">
 521+
 522+
 523+
 524+=1=
 525+a
 526+b
 527+
 528+
 529+=2=
 530+
 531+a
 532+
 533+b
 534+== 3 ==
 535+*a
 536+*b
 537+#c
 538+#d
 539+1
 540+*1
 541+
 542+1
 543+=== 4===
 544+=5 =
 545+=== 6 ===
 546+1 2 3 4
 547+ a
 548+2
 549+
 550+3
 551+
 552+
 553+
 554+
 555+
 556+ a</text></revision></page>
 557+<page><id>72</id><title>Wikia RTE round-trip test 72</title><revision><id>72</id><text xml:space="preserve">{|
 558+|123
 559+|}</text></revision></page>
 560+<page><id>73</id><title>Wikia RTE round-trip test 73</title><revision><id>73</id><text xml:space="preserve">
 561+{|
 562+|123
 563+|}</text></revision></page>
 564+<page><id>74</id><title>Wikia RTE round-trip test 74</title><revision><id>74</id><text xml:space="preserve">
 565+
 566+{|
 567+|123
 568+|}</text></revision></page>
 569+<page><id>75</id><title>Wikia RTE round-trip test 75</title><revision><id>75</id><text xml:space="preserve">
 570+
 571+
 572+{|
 573+|123
 574+|}</text></revision></page>
 575+<page><id>76</id><title>Wikia RTE round-trip test 76</title><revision><id>76</id><text xml:space="preserve">{|
 576+|123
 577+|}
 578+{|
 579+|123
 580+|}</text></revision></page>
 581+<page><id>77</id><title>Wikia RTE round-trip test 77</title><revision><id>77</id><text xml:space="preserve">{|
 582+|123
 583+|}
 584+
 585+{|
 586+|123
 587+|}</text></revision></page>
 588+<page><id>78</id><title>Wikia RTE round-trip test 78</title><revision><id>78</id><text xml:space="preserve">{|
 589+|123
 590+|}
 591+
 592+
 593+{|
 594+|123
 595+|}</text></revision></page>
 596+<page><id>79</id><title>Wikia RTE round-trip test 79</title><revision><id>79</id><text xml:space="preserve">{|
 597+|123
 598+|}
 599+
 600+
 601+
 602+{|
 603+|123
 604+|}</text></revision></page>
 605+<page><id>80</id><title>Wikia RTE round-trip test 80</title><revision><id>80</id><text xml:space="preserve">{|
 606+|123||456
 607+|-
 608+|abc
 609+|def
 610+|}</text></revision></page>
 611+<page><id>81</id><title>Wikia RTE round-trip test 81</title><revision><id>81</id><text xml:space="preserve">{|
 612+!abc
 613+!def
 614+|-
 615+!123!!456
 616+|-
 617+|abc
 618+|def
 619+|}</text></revision></page>
 620+<page><id>82</id><title>Wikia RTE round-trip test 82</title><revision><id>82</id><text xml:space="preserve">{| border=&quot;1&quot;
 621+|foo
 622+|}</text></revision></page>
 623+<page><id>83</id><title>Wikia RTE round-trip test 83</title><revision><id>83</id><text xml:space="preserve">{|
 624+|123
 625+{|
 626+|123
 627+|}
 628+{|
 629+|123
 630+|}
 631+|}</text></revision></page>
 632+<page><id>84</id><title>Wikia RTE round-trip test 84</title><revision><id>84</id><text xml:space="preserve">{|
 633+|
 634+{|
 635+|
 636+{|
 637+|123
 638+|}
 639+|}
 640+|}</text></revision></page>
 641+<page><id>85</id><title>Wikia RTE round-trip test 85</title><revision><id>85</id><text xml:space="preserve">{|
 642+|
 643+123
 644+|}</text></revision></page>
 645+<page><id>86</id><title>Wikia RTE round-trip test 86</title><revision><id>86</id><text xml:space="preserve">{|
 646+|
 647+*123
 648+|}</text></revision></page>
 649+<page><id>87</id><title>Wikia RTE round-trip test 87</title><revision><id>87</id><text xml:space="preserve">{|
 650+|
 651+==123==
 652+|}</text></revision></page>
 653+<page><id>88</id><title>Wikia RTE round-trip test 88</title><revision><id>88</id><text xml:space="preserve">{|
 654+|
 655+ 123
 656+|}</text></revision></page>
 657+<page><id>89</id><title>Wikia RTE round-trip test 89</title><revision><id>89</id><text xml:space="preserve">{|
 658+|123
 659+456
 660+|}</text></revision></page>
 661+<page><id>90</id><title>Wikia RTE round-trip test 90</title><revision><id>90</id><text xml:space="preserve">{| border=&quot;1&quot;
 662+|+foo
 663+|- style=&quot;color: red;&quot;
 664+|123
 665+| align=&quot;right&quot;|456
 666+|}</text></revision></page>
 667+<page><id>91</id><title>Wikia RTE round-trip test 91</title><revision><id>91</id><text xml:space="preserve">{| style=&quot;color: red;&quot; class=&quot;table&quot;
 668+|+ align=&quot;bottom&quot; style=&quot;color:#66f&quot;|foo
 669+|bar
 670+|}</text></revision></page>
 671+<page><id>92</id><title>Wikia RTE round-trip test 92</title><revision><id>92</id><text xml:space="preserve">{| style=&quot;color: blue&quot;
 672+|123
 673+|}
 674+
 675+{|style=&quot;color: #f00;border:solid 1px green&quot;
 676+|123
 677+|}</text></revision></page>
 678+<page><id>93</id><title>Wikia RTE round-trip test 93</title><revision><id>93</id><text xml:space="preserve">{|
 679+|+foo
 680+!bar
 681+|-
 682+|123
 683+|}</text></revision></page>
 684+<page><id>94</id><title>Wikia RTE round-trip test 94</title><revision><id>94</id><text xml:space="preserve">{|
 685+|Test
 686+{|
 687+|Test
 688+|}
 689+|}</text></revision></page>
 690+<page><id>95</id><title>Wikia RTE round-trip test 95</title><revision><id>95</id><text xml:space="preserve">foo
 691+{|
 692+|bar
 693+|}
 694+foo</text></revision></page>
 695+<page><id>96</id><title>Wikia RTE round-trip test 96</title><revision><id>96</id><text xml:space="preserve">foo
 696+
 697+{|
 698+|bar
 699+|}
 700+
 701+
 702+foo</text></revision></page>
 703+<page><id>97</id><title>Wikia RTE round-trip test 97</title><revision><id>97</id><text xml:space="preserve">*foo
 704+{|
 705+|bar
 706+|}
 707+ foo</text></revision></page>
 708+<page><id>98</id><title>Wikia RTE round-trip test 98</title><revision><id>98</id><text xml:space="preserve">=foo=
 709+{|
 710+|bar
 711+|}
 712+
 713+foo</text></revision></page>
 714+<page><id>99</id><title>Wikia RTE round-trip test 99</title><revision><id>99</id><text xml:space="preserve">123 [[bar]] 456</text></revision></page>
 715+<page><id>100</id><title>Wikia RTE round-trip test 100</title><revision><id>100</id><text xml:space="preserve">abc [[foo|bar]] def</text></revision></page>
 716+<page><id>101</id><title>Wikia RTE round-trip test 101</title><revision><id>101</id><text xml:space="preserve">[[:Category:foo]] 123</text></revision></page>
 717+<page><id>102</id><title>Wikia RTE round-trip test 102</title><revision><id>102</id><text xml:space="preserve">[[Foo]]s 123</text></revision></page>
 718+<page><id>103</id><title>Wikia RTE round-trip test 103</title><revision><id>103</id><text xml:space="preserve">[[#Foo]] 123</text></revision></page>
 719+<page><id>104</id><title>Wikia RTE round-trip test 104</title><revision><id>104</id><text xml:space="preserve">[[/foo]] 123</text></revision></page>
 720+<page><id>105</id><title>Wikia RTE round-trip test 105</title><revision><id>105</id><text xml:space="preserve">[[foo &amp; bar]]</text></revision></page>
 721+<page><id>106</id><title>Wikia RTE round-trip test 106</title><revision><id>106</id><text xml:space="preserve">[[File:6.jpg]] 123</text></revision></page>
 722+<page><id>107</id><title>Wikia RTE round-trip test 107</title><revision><id>107</id><text xml:space="preserve">[[File:6.jpg|thumb|caption]] 123</text></revision></page>
 723+<page><id>108</id><title>Wikia RTE round-trip test 108</title><revision><id>108</id><text xml:space="preserve">[[File:6.jpg|center]] 123</text></revision></page>
 724+<page><id>109</id><title>Wikia RTE round-trip test 109</title><revision><id>109</id><text xml:space="preserve">[[File:6.jpg|frame]] 123</text></revision></page>
 725+<page><id>110</id><title>Wikia RTE round-trip test 110</title><revision><id>110</id><text xml:space="preserve">[[File:6.jpg|120px]] 123</text></revision></page>
 726+<page><id>111</id><title>Wikia RTE round-trip test 111</title><revision><id>111</id><text xml:space="preserve">[[File:IAmBrokenImageLink]] 123 [[File:IAmBrokenImageLink|thumb]] 123 [[File:IAmBrokenImageLink|120px|bla bla bla]] 123</text></revision></page>
 727+<page><id>112</id><title>Wikia RTE round-trip test 112</title><revision><id>112</id><text xml:space="preserve">[[File:Wiki.png|thumb|caption [[test]] ''aaa'' '''bar''']]</text></revision></page>
 728+<page><id>113</id><title>Wikia RTE round-trip test 113</title><revision><id>113</id><text xml:space="preserve">[[File:B0rken.png|thumb|caption [[test]] ''aaa'' '''bar''']]</text></revision></page>
 729+<page><id>114</id><title>Wikia RTE round-trip test 114</title><revision><id>114</id><text xml:space="preserve">[[Video:Video.png|caption [[foo]] ''aaa'' '''bar''']]</text></revision></page>
 730+<page><id>115</id><title>Wikia RTE round-trip test 115</title><revision><id>115</id><text xml:space="preserve">[[Video:B0rken.png|caption [[foo]] ''aaa'' '''bar''']]</text></revision></page>
 731+<page><id>116</id><title>Wikia RTE round-trip test 116</title><revision><id>116</id><text xml:space="preserve">[http://wp.pl]
 732+
 733+[http://wp.pl foo]
 734+
 735+[mailto:info@example.org email me]
 736+
 737+[http://wp.pl]
 738+
 739+[mailto:info@example.org?Subject=URL%20Encoded%20Subject&amp;body=Body%20Text info]</text></revision></page>
 740+<page><id>117</id><title>Wikia RTE round-trip test 117</title><revision><id>117</id><text xml:space="preserve">[http://wp.pl]
 741+
 742+http://onet.pl
 743+
 744+[http://wp.pl foo]</text></revision></page>
 745+<page><id>118</id><title>Wikia RTE round-trip test 118</title><revision><id>118</id><text xml:space="preserve">[[Bart|&lt;span style='color:#1A2BBB'&gt;foo&lt;/span&gt;]]</text></revision></page>
 746+<page><id>119</id><title>Wikia RTE round-trip test 119</title><revision><id>119</id><text xml:space="preserve">[[Bart|&lt;span style=&quot;color:#1A2BBB&quot;&gt;foo&lt;/span&gt;]]</text></revision></page>
 747+<page><id>120</id><title>Wikia RTE round-trip test 120</title><revision><id>120</id><text xml:space="preserve">&lt;span style=&quot;font-family: 'comic sans ms'; color:#666&quot;&gt;foo&lt;/span&gt;</text></revision></page>
 748+<page><id>121</id><title>Wikia RTE round-trip test 121</title><revision><id>121</id><text xml:space="preserve">''i'' '''b''' - '''''bi'' b''' - '''''bi''' i''</text></revision></page>
 749+<page><id>122</id><title>Wikia RTE round-trip test 122</title><revision><id>122</id><text xml:space="preserve">{{123}}</text></revision></page>
 750+<page><id>123</id><title>Wikia RTE round-trip test 123</title><revision><id>123</id><text xml:space="preserve">inline template {{123}}</text></revision></page>
 751+<page><id>124</id><title>Wikia RTE round-trip test 124</title><revision><id>124</id><text xml:space="preserve">* {{123}} {{abc}}
 752+*{{456}}
 753+**{{789}}
 754+# {{123}} {{abc}}
 755+#{{456}}
 756+##{{789}}
 757+: {{123}} {{abc}}
 758+:{{456}}
 759+::{{789}}
 760+
 761+
 762+::*: {{foo}}
 763+:::# {{bar}}</text></revision></page>
 764+<page><id>125</id><title>Wikia RTE round-trip test 125</title><revision><id>125</id><text xml:space="preserve">{{123|
 765+foo=bar}}</text></revision></page>
 766+<page><id>126</id><title>Wikia RTE round-trip test 126</title><revision><id>126</id><text xml:space="preserve">{|
 767+|+caption
 768+| 123
 769+|}</text></revision></page>
 770+<page><id>127</id><title>Wikia RTE round-trip test 127</title><revision><id>127</id><text xml:space="preserve">{|
 771+| style=&quot;color:blue&quot;| 123
 772+| style=&quot;color:red&quot; |456
 773+|}</text></revision></page>
 774+<page><id>128</id><title>Wikia RTE round-trip test 128</title><revision><id>128</id><text xml:space="preserve">&lt;b style=&quot;color: red&quot;&gt;a''b''
 775+&lt;/b&gt;</text></revision></page>
 776+<page><id>129</id><title>Wikia RTE round-trip test 129</title><revision><id>129</id><text xml:space="preserve">foo&lt;br /&gt;bar&lt;b style=&quot;color: #f55;&quot;&gt;foo&lt;/b&gt; '''bar'''</text></revision></page>
 777+<page><id>130</id><title>Wikia RTE round-trip test 130</title><revision><id>130</id><text xml:space="preserve">&lt;strike&gt;123&lt;/strike&gt;
 778+
 779+456</text></revision></page>
 780+<page><id>131</id><title>Wikia RTE round-trip test 131</title><revision><id>131</id><text xml:space="preserve">
 781+&lt;ul&gt;
 782+&lt;li&gt;foo&lt;/li&gt;
 783+&lt;li&gt;foo&lt;/li&gt;&lt;li&gt;foo&lt;/li&gt;
 784+&lt;/ul&gt;
 785+
 786+123
 787+
 788+
 789+&lt;ul&gt;&lt;li&gt;foo&lt;/li&gt;&lt;/ul&gt;</text></revision></page>
 790+<page><id>132</id><title>Wikia RTE round-trip test 132</title><revision><id>132</id><text xml:space="preserve">123&lt;br /&gt;456
 791+
 792+123
 793+&lt;br /&gt;
 794+456
 795+
 796+123&lt;br /&gt;
 797+456
 798+
 799+123
 800+&lt;br /&gt;456</text></revision></page>
 801+<page><id>133</id><title>Wikia RTE round-trip test 133</title><revision><id>133</id><text xml:space="preserve">: 123
 802+;456
 803+
 804+: 789
 805+
 806+
 807+
 808+;foo
 809+
 810+
 811+:abc
 812+;def</text></revision></page>
 813+<page><id>134</id><title>Wikia RTE round-trip test 134</title><revision><id>134</id><text xml:space="preserve">:1
 814+::2
 815+:::3
 816+::::4
 817+abc
 818+
 819+::d</text></revision></page>
 820+<page><id>135</id><title>Wikia RTE round-trip test 135</title><revision><id>135</id><text xml:space="preserve">:::*1
 821+:::**2
 822+:::**3</text></revision></page>
 823+<page><id>136</id><title>Wikia RTE round-trip test 136</title><revision><id>136</id><text xml:space="preserve">:::*1
 824+:::**2
 825+:::#* 3
 826+:::#*#4</text></revision></page>
 827+<page><id>137</id><title>Wikia RTE round-trip test 137</title><revision><id>137</id><text xml:space="preserve">:::*:#foo
 828+:::# bar</text></revision></page>
 829+<page><id>138</id><title>Wikia RTE round-trip test 138</title><revision><id>138</id><text xml:space="preserve">::*:#foo
 830+:::# bar</text></revision></page>
 831+<page><id>139</id><title>Wikia RTE round-trip test 139</title><revision><id>139</id><text xml:space="preserve">:One
 832+:* Two
 833+:**Three</text></revision></page>
 834+<page><id>140</id><title>Wikia RTE round-trip test 140</title><revision><id>140</id><text xml:space="preserve">;ReverseParser rox
 835+;*foo
 836+;*bar</text></revision></page>
 837+<page><id>141</id><title>Wikia RTE round-trip test 141</title><revision><id>141</id><text xml:space="preserve">
 838+[[Category:a]]
 839+[[Category:b]] [[Category:c]] [[Category:d]] [[Category:e]]
 840+
 841+* [[Category:f]]
 842+** [[Category:g]]h
 843+*** i[[Category:j]]
 844+{|
 845+|[[Category:1]]
 846+| [[Category:2]]
 847+|-
 848+|a[[Category:3]]
 849+|a
 850+[[Category:4]]b
 851+|}
 852+ [[Category:5]] abc</text></revision></page>
 853+<page><id>142</id><title>Wikia RTE round-trip test 142</title><revision><id>142</id><text xml:space="preserve">__TOC__
 854+
 855+{{PAGENAME}}
 856+
 857+__NOTOC__</text></revision></page>
 858+<page><id>143</id><title>Wikia RTE round-trip test 143</title><revision><id>143</id><text xml:space="preserve">:: __TOC__
 859+
 860+{|
 861+|
 862+
 863+ {{PAGENAME}}
 864+| __NOTOC__
 865+|}</text></revision></page>
 866+<page><id>144</id><title>Wikia RTE round-trip test 144</title><revision><id>144</id><text xml:space="preserve">&lt;includeonly&gt;abc
 867+&lt;/includeonly&gt;
 868+
 869+&lt;includeonly&gt;abc&lt;/includeonly&gt;
 870+
 871+&lt;includeonly&gt;
 872+abc&lt;/includeonly&gt;</text></revision></page>
 873+<page><id>145</id><title>Wikia RTE round-trip test 145</title><revision><id>145</id><text xml:space="preserve">{{localurl:fullpagename}}
 874+
 875+{{#language:pl}}</text></revision></page>
 876+<page><id>146</id><title>Wikia RTE round-trip test 146</title><revision><id>146</id><text xml:space="preserve">I'm, you're
 877+&quot;ąźół&quot;</text></revision></page>
 878+<page><id>147</id><title>Wikia RTE round-trip test 147</title><revision><id>147</id><text xml:space="preserve">
 879+
 880+
 881+&lt;includeonly&gt;abc&lt;/includeonly&gt;
 882+
 883+
 884+&lt;includeonly&gt;abc&lt;/includeonly&gt;
 885+*&lt;includeonly&gt;abc&lt;/includeonly&gt;
 886+* &lt;includeonly&gt;abc&lt;/includeonly&gt;
 887+* &lt;includeonly&gt;abc&lt;/includeonly&gt;
 888+* &lt;includeonly&gt;abc&lt;/includeonly&gt;
 889+**&lt;includeonly&gt;abc&lt;/includeonly&gt;
 890+***&lt;includeonly&gt;abc&lt;/includeonly&gt;
 891+
 892+#&lt;includeonly&gt;abc&lt;/includeonly&gt;
 893+# &lt;includeonly&gt;abc&lt;/includeonly&gt;
 894+# &lt;includeonly&gt;abc&lt;/includeonly&gt;
 895+# &lt;includeonly&gt;abc&lt;/includeonly&gt;
 896+##&lt;includeonly&gt;abc&lt;/includeonly&gt;
 897+ &lt;includeonly&gt;abc&lt;/includeonly&gt;
 898+ &lt;includeonly&gt;abc&lt;/includeonly&gt;
 899+ &lt;includeonly&gt;abc&lt;/includeonly&gt;
 900+&lt;includeonly abc='def' ghi&gt;abc&lt;/includeonly&gt;</text></revision></page>
 901+<page><id>148</id><title>Wikia RTE round-trip test 148</title><revision><id>148</id><text xml:space="preserve">
 902+
 903+
 904+~~~
 905+
 906+
 907+~~~
 908+*~~~
 909+* ~~~
 910+* ~~~
 911+* ~~~
 912+**~~~
 913+***~~~
 914+
 915+#~~~
 916+# ~~~
 917+# ~~~
 918+# ~~~
 919+##~~~
 920+ ~~~
 921+ ~~~~
 922+ ~~~~
 923+~~~~</text></revision></page>
 924+<page><id>149</id><title>Wikia RTE round-trip test 149</title><revision><id>149</id><text xml:space="preserve">[a]
 925+[[a]
 926+[[[a]
 927+[[[[a]
 928+[[[[[a]
 929+[[[[[[a]
 930+[[[[[[[a]
 931+[a]]
 932+[a]]]
 933+[a]]]]
 934+[a]]]]]
 935+[a]]]]]]
 936+[a]]]]]]]
 937+[a]
 938+[[a]]
 939+[[[a]]]
 940+[[[[a]]]]
 941+[[[[[a]]]]]
 942+[[[[[[a]]]]]]
 943+[[[[[[[a]]]]]]]
 944+[[[[[[[[a]]]]]]]]
 945+[[[[[[[[[a]]]]]]]]]</text></revision></page>
 946+<page><id>150</id><title>Wikia RTE round-trip test 150</title><revision><id>150</id><text xml:space="preserve">[[Sideshow_Bob_Roberts[[Sideshow_Bob_Roberts[[Sideshow_Bob_Roberts]]]]]][[Sideshow Bob Roberts[[Sideshow Bob Roberts[[Sideshow Bob Roberts]]]]]]</text></revision></page>
 947+<page><id>151</id><title>Wikia RTE round-trip test 151</title><revision><id>151</id><text xml:space="preserve">&lt;te&amp;st&gt;a&amp;b&amp;c&lt;/te&lt;&amp;&gt;st&gt; &amp;amp; &amp;nbsp; &amp;lt; &amp;gt; : &amp;#58; &amp;#123; - 123 &amp;#x5f;</text></revision></page>
 948+<page><id>152</id><title>Wikia RTE round-trip test 152</title><revision><id>152</id><text xml:space="preserve">&lt;noinclude&gt;&amp;#91;brackets&amp;#93;&amp;nbsp;&amp;amp;&amp;nbsp;non-breaking&amp;nbsp;spaces&lt;/noinclude&gt;
 949+
 950+&lt;noinclude&gt;[brackets] &amp; non-breaking spaces&lt;/noinclude&gt;</text></revision></page>
 951+<page><id>153</id><title>Wikia RTE round-trip test 153</title><revision><id>153</id><text xml:space="preserve">« foo</text></revision></page>
 952+<page><id>154</id><title>Wikia RTE round-trip test 154</title><revision><id>154</id><text xml:space="preserve">ÀàĄąÒòỪừỲỳŹź</text></revision></page>
 953+<page><id>155</id><title>Wikia RTE round-trip test 155</title><revision><id>155</id><text xml:space="preserve">(義) (誠) (涅 ネム) foo</text></revision></page>
 954+<page><id>156</id><title>Wikia RTE round-trip test 156</title><revision><id>156</id><text xml:space="preserve">foo ? ;-) bar</text></revision></page>
 955+<page><id>157</id><title>Wikia RTE round-trip test 157</title><revision><id>157</id><text xml:space="preserve">bar „foo“ ;)</text></revision></page>
 956+<page><id>158</id><title>Wikia RTE round-trip test 158</title><revision><id>158</id><text xml:space="preserve">[[&amp;]]
 957+
 958+[[&amp;amp;]]
 959+
 960+[[foo &amp; bar]]es
 961+
 962+[[Flip &amp; Flap]]
 963+
 964+[[Flip &amp; Flap|and &amp;amp; entity]]
 965+
 966+[[Flip &amp;amp; Entity]]
 967+
 968+foo &amp; bar
 969+
 970+foo &amp;amp; entity
 971+
 972+[[foo|&amp;amp;]]
 973+
 974+[[foo|Caption with &amp;amp; entity]]</text></revision></page>
 975+<page><id>159</id><title>Wikia RTE round-trip test 159</title><revision><id>159</id><text xml:space="preserve">[[/foo]]
 976+
 977+[[/foo/]]
 978+
 979+[[/foo bar]]
 980+
 981+[[/foo bar/]]</text></revision></page>
 982+<page><id>160</id><title>Wikia RTE round-trip test 160</title><revision><id>160</id><text xml:space="preserve">[[RTE_test_page/foo|foo]]
 983+
 984+[[/foo/]]
 985+
 986+[[RTE_test_page/foo|bar]]
 987+
 988+[[RTE_test_page/foo]]</text></revision></page>
 989+<page><id>161</id><title>Wikia RTE round-trip test 161</title><revision><id>161</id><text xml:space="preserve">
 990+&lt;div&gt;123&lt;/div&gt;
 991+
 992+&lt;div&gt;456&lt;/div&gt;
 993+
 994+
 995+&lt;div&gt;789&lt;/div&gt;</text></revision></page>
 996+<page><id>162</id><title>Wikia RTE round-trip test 162</title><revision><id>162</id><text xml:space="preserve">&lt;div&gt;123&lt;/div&gt;
 997+
 998+&lt;div&gt;456&lt;/div&gt;
 999+
 1000+
 1001+
 1002+&lt;div&gt;
 1003+
 1004+
 1005+789&lt;/div&gt;</text></revision></page>
 1006+<page><id>163</id><title>Wikia RTE round-trip test 163</title><revision><id>163</id><text xml:space="preserve">&lt;div&gt;
 1007+
 1008+{|
 1009+|123
 1010+|}
 1011+&lt;/div&gt;</text></revision></page>
 1012+<page><id>164</id><title>Wikia RTE round-trip test 164</title><revision><id>164</id><text xml:space="preserve">&lt;div&gt;
 1013+
 1014+
 1015+ pre
 1016+&lt;/div&gt;</text></revision></page>
 1017+<page><id>165</id><title>Wikia RTE round-trip test 165</title><revision><id>165</id><text xml:space="preserve">&lt;div&gt;
 1018+* 123
 1019+&lt;/div&gt;
 1020+
 1021+&lt;div&gt;
 1022+# 123
 1023+&lt;/div&gt;
 1024+
 1025+&lt;div&gt;
 1026+: 123
 1027+&lt;/div&gt;</text></revision></page>
 1028+<page><id>166</id><title>Wikia RTE round-trip test 166</title><revision><id>166</id><text xml:space="preserve">&lt;div&gt;
 1029+&lt;span&gt;foo&lt;/span&gt;
 1030+&lt;/div&gt;
 1031+
 1032+&lt;div&gt;
 1033+
 1034+&lt;span&gt;foo&lt;/span&gt;
 1035+&lt;/div&gt;
 1036+
 1037+
 1038+&lt;div&gt;&lt;span&gt;foo&lt;/span&gt;&lt;/div&gt;</text></revision></page>
 1039+<page><id>167</id><title>Wikia RTE round-trip test 167</title><revision><id>167</id><text xml:space="preserve">&lt;div&gt;
 1040+
 1041+
 1042+{|
 1043+|123
 1044+|}
 1045+
 1046+
 1047+&lt;/div&gt;</text></revision></page>
 1048+<page><id>168</id><title>Wikia RTE round-trip test 168</title><revision><id>168</id><text xml:space="preserve">{|
 1049+|&lt;div class=&quot;foo&quot;&gt; &lt;/div&gt;
 1050+{|
 1051+|bar
 1052+|}
 1053+|}</text></revision></page>
 1054+<page><id>169</id><title>Wikia RTE round-trip test 169</title><revision><id>169</id><text xml:space="preserve">&lt;div&gt;
 1055+== foo ==
 1056+
 1057+bar
 1058+&lt;/div&gt;</text></revision></page>
 1059+<page><id>170</id><title>Wikia RTE round-trip test 170</title><revision><id>170</id><text xml:space="preserve">&lt;div&gt;123&lt;/div&gt;</text></revision></page>
 1060+<page><id>171</id><title>Wikia RTE round-trip test 171</title><revision><id>171</id><text xml:space="preserve">&lt;div&gt;
 1061+123
 1062+&lt;/div&gt;</text></revision></page>
 1063+<page><id>172</id><title>Wikia RTE round-trip test 172</title><revision><id>172</id><text xml:space="preserve">&lt;div&gt;
 1064+
 1065+123
 1066+&lt;/div&gt;</text></revision></page>
 1067+<page><id>173</id><title>Wikia RTE round-trip test 173</title><revision><id>173</id><text xml:space="preserve">&lt;div&gt;
 1068+
 1069+
 1070+123
 1071+&lt;/div&gt;</text></revision></page>
 1072+<page><id>174</id><title>Wikia RTE round-trip test 174</title><revision><id>174</id><text xml:space="preserve">&lt;div&gt;
 1073+&lt;ul&gt;
 1074+&lt;li&gt;foo&lt;/li&gt;&lt;/ul&gt;
 1075+&lt;/div&gt;</text></revision></page>
 1076+<page><id>175</id><title>Wikia RTE round-trip test 175</title><revision><id>175</id><text xml:space="preserve">&lt;div&gt;
 1077+
 1078+&lt;ul&gt;
 1079+&lt;li&gt;foo&lt;/li&gt;&lt;/ul&gt;
 1080+&lt;/div&gt;</text></revision></page>
 1081+<page><id>176</id><title>Wikia RTE round-trip test 176</title><revision><id>176</id><text xml:space="preserve">&lt;div&gt;
 1082+
 1083+
 1084+&lt;ul&gt;
 1085+&lt;li&gt;foo&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;</text></revision></page>
 1086+<page><id>177</id><title>Wikia RTE round-trip test 177</title><revision><id>177</id><text xml:space="preserve">&lt;div&gt;one
 1087+
 1088+two
 1089+
 1090+three&lt;/div&gt;</text></revision></page>
 1091+<page><id>178</id><title>Wikia RTE round-trip test 178</title><revision><id>178</id><text xml:space="preserve">&lt;div&gt;1
 1092+
 1093+2
 1094+
 1095+3
 1096+
 1097+4
 1098+
 1099+5
 1100+
 1101+6&lt;/div&gt;</text></revision></page>
 1102+<page><id>179</id><title>Wikia RTE round-trip test 179</title><revision><id>179</id><text xml:space="preserve">&lt;div&gt;one
 1103+
 1104+two
 1105+
 1106+----
 1107+
 1108+three
 1109+
 1110+four&lt;/div&gt;</text></revision></page>
 1111+<page><id>180</id><title>Wikia RTE round-trip test 180</title><revision><id>180</id><text xml:space="preserve">&lt;div&gt;
 1112+
 1113+&lt;h2&gt;foo&lt;/h2&gt;
 1114+
 1115+{|
 1116+|bar
 1117+|}
 1118+
 1119+&lt;/div&gt;</text></revision></page>
 1120+<page><id>181</id><title>Wikia RTE round-trip test 181</title><revision><id>181</id><text xml:space="preserve">&lt;div&gt;&lt;div&gt;&lt;span&gt;foo&lt;/span&gt;&lt;/div&gt;
 1121+&lt;!-- bar --&gt;
 1122+&lt;/div&gt;</text></revision></page>
 1123+<page><id>182</id><title>Wikia RTE round-trip test 182</title><revision><id>182</id><text xml:space="preserve">&lt;div&gt;&lt;div&gt;&lt;span&gt;foo&lt;/span&gt;&lt;/div&gt;
 1124+
 1125+&lt;!-- bar --&gt;
 1126+&lt;/div&gt;</text></revision></page>
 1127+<page><id>183</id><title>Wikia RTE round-trip test 183</title><revision><id>183</id><text xml:space="preserve">&lt;p style=&quot;text-align:right&quot;&gt;123&lt;/p&gt;
 1128+
 1129+
 1130+
 1131+456</text></revision></page>
 1132+<page><id>184</id><title>Wikia RTE round-trip test 184</title><revision><id>184</id><text xml:space="preserve">&lt;p style=&quot;text-align:right;&quot;&gt;123&lt;/p&gt;
 1133+
 1134+
 1135+
 1136+456</text></revision></page>
 1137+<page><id>185</id><title>Wikia RTE round-trip test 185</title><revision><id>185</id><text xml:space="preserve">&lt;p style=&quot;text-align: center; margin-left:40px;font-size: 150%;&quot;&gt;foo&lt;/p&gt;</text></revision></page>
 1138+<page><id>186</id><title>Wikia RTE round-trip test 186</title><revision><id>186</id><text xml:space="preserve">&lt;p style=&quot;text-align:center; font-size: 150%&quot;&gt;foo&lt;/p&gt;</text></revision></page>
 1139+<page><id>187</id><title>Wikia RTE round-trip test 187</title><revision><id>187</id><text xml:space="preserve">&lt;p style=&quot;text-indent:4em&quot;&gt;foo&lt;/p&gt;</text></revision></page>
 1140+<page><id>188</id><title>Wikia RTE round-trip test 188</title><revision><id>188</id><text xml:space="preserve">&lt;p style=&quot;text-align: center; height: 3em;&quot;&gt;&amp;#160;&lt;/p&gt;</text></revision></page>
 1141+<page><id>189</id><title>Wikia RTE round-trip test 189</title><revision><id>189</id><text xml:space="preserve">&lt;p style=&quot;text-align: center; height: 3em;&quot;&gt;123&amp;#160;456&lt;/p&gt;</text></revision></page>
 1142+<page><id>190</id><title>Wikia RTE round-trip test 190</title><revision><id>190</id><text xml:space="preserve">foo
 1143+
 1144+&lt;!--123 --&gt;
 1145+
 1146+bar</text></revision></page>
 1147+<page><id>191</id><title>Wikia RTE round-trip test 191</title><revision><id>191</id><text xml:space="preserve">abc
 1148+
 1149+
 1150+&lt;!--123
 1151+456
 1152+789
 1153+--&gt;</text></revision></page>
 1154+<page><id>192</id><title>Wikia RTE round-trip test 192</title><revision><id>192</id><text xml:space="preserve">{|
 1155+! foo
 1156+|-
 1157+| bar
 1158+|}</text></revision></page>
 1159+<page><id>193</id><title>Wikia RTE round-trip test 193</title><revision><id>193</id><text xml:space="preserve">foo
 1160+
 1161+http://images3.wikia.nocookie.net/kirkburn/images/a/a9/Example.jpg
 1162+
 1163+bar</text></revision></page>
 1164+<page><id>194</id><title>Wikia RTE round-trip test 194</title><revision><id>194</id><text xml:space="preserve">&lt;br /&gt;&lt;br /&gt;123</text></revision></page>
 1165+<page><id>195</id><title>Wikia RTE round-trip test 195</title><revision><id>195</id><text xml:space="preserve">&lt;br /&gt;
 1166+&lt;br /&gt;
 1167+
 1168+foo
 1169+
 1170+&lt;br /&gt;&lt;br /&gt;
 1171+&lt;br /&gt;
 1172+&lt;br /&gt;</text></revision></page>
 1173+<page><id>196</id><title>Wikia RTE round-trip test 196</title><revision><id>196</id><text xml:space="preserve">123
 1174+
 1175+&lt;br style=&quot;clear:both&quot; /&gt;
 1176+
 1177+== 456 ==</text></revision></page>
 1178+<page><id>197</id><title>Wikia RTE round-trip test 197</title><revision><id>197</id><text xml:space="preserve">* a
 1179+* b
 1180+*: c
 1181+*: d
 1182+*: e
 1183+** f
 1184+**: g
 1185+**: h</text></revision></page>
 1186+<page><id>198</id><title>Wikia RTE round-trip test 198</title><revision><id>198</id><text xml:space="preserve">* abc
 1187+** def
 1188+*# ghi
 1189+
 1190+* abc
 1191+** def
 1192+
 1193+*# ghi</text></revision></page>
 1194+<page><id>199</id><title>Wikia RTE round-trip test 199</title><revision><id>199</id><text xml:space="preserve">== test ==
 1195+*
 1196+** foo
 1197+** bar
 1198+*** 123
 1199+*</text></revision></page>
 1200+<page><id>200</id><title>Wikia RTE round-trip test 200</title><revision><id>200</id><text xml:space="preserve">&lt;div&gt;foo
 1201+*bar
 1202+&lt;/div&gt;
 1203+
 1204+&lt;div&gt;foo
 1205+{|
 1206+|123
 1207+|}
 1208+&lt;/div&gt;</text></revision></page>
 1209+<page><id>201</id><title>Wikia RTE round-trip test 201</title><revision><id>201</id><text xml:space="preserve">&lt;div&gt;123
 1210+
 1211+{|
 1212+|123
 1213+|}
 1214+&lt;/div&gt;</text></revision></page>
 1215+<page><id>202</id><title>Wikia RTE round-trip test 202</title><revision><id>202</id><text xml:space="preserve">&lt;div&gt;&lt;span&gt;foo&lt;/span&gt;
 1216+{|
 1217+|bar
 1218+|}
 1219+&lt;/div&gt;</text></revision></page>
 1220+<page><id>203</id><title>Wikia RTE round-trip test 203</title><revision><id>203</id><text xml:space="preserve">&lt;div&gt;&lt;span&gt;foo&lt;/span&gt;
 1221+
 1222+{|
 1223+|bar
 1224+|}
 1225+&lt;/div&gt;</text></revision></page>
 1226+<page><id>204</id><title>Wikia RTE round-trip test 204</title><revision><id>204</id><text xml:space="preserve">123
 1227+----
 1228+456
 1229+
 1230+789
 1231+
 1232+----
 1233+
 1234+abc</text></revision></page>
 1235+<page><id>205</id><title>Wikia RTE round-trip test 205</title><revision><id>205</id><text xml:space="preserve">{|
 1236+|foo [[bar]]
 1237+|foo '''bar'''
 1238+|}</text></revision></page>
 1239+<page><id>206</id><title>Wikia RTE round-trip test 206</title><revision><id>206</id><text xml:space="preserve">{|
 1240+| foo &amp;rarr; bar
 1241+| 123 &amp;nbsp; 456
 1242+|-
 1243+| abc &amp;mdash;
 1244+| def &amp;nbsp;
 1245+|}</text></revision></page>
 1246+<page><id>207</id><title>Wikia RTE round-trip test 207</title><revision><id>207</id><text xml:space="preserve">{|
 1247+|
 1248+----
 1249+foo
 1250+|
 1251+
 1252+----
 1253+foo
 1254+|}</text></revision></page>
 1255+<page><id>208</id><title>Wikia RTE round-trip test 208</title><revision><id>208</id><text xml:space="preserve">[[File:Foo.ogg]]</text></revision></page>
 1256+<page><id>209</id><title>Wikia RTE round-trip test 209</title><revision><id>209</id><text xml:space="preserve">[[Media:Wiki.png]]
 1257+
 1258+[[File:Wiki.png]]
 1259+
 1260+[[Media:Foo.png]]</text></revision></page>
 1261+<page><id>210</id><title>Wikia RTE round-trip test 210</title><revision><id>210</id><text xml:space="preserve">[[Image:Placeholder]]</text></revision></page>
 1262+<page><id>211</id><title>Wikia RTE round-trip test 211</title><revision><id>211</id><text xml:space="preserve">[[Image:Placeholder|thumb|200px|foo caption bar]]</text></revision></page>
 1263+<page><id>212</id><title>Wikia RTE round-trip test 212</title><revision><id>212</id><text xml:space="preserve">[[Video:SomethingNotExisting]]</text></revision></page>
 1264+<page><id>213</id><title>Wikia RTE round-trip test 213</title><revision><id>213</id><text xml:space="preserve">{|
 1265+! Text !! Text !! Text
 1266+|-
 1267+| foo || bar|| 123
 1268+|-
 1269+|1
 1270+| 2
 1271+| 3
 1272+|}</text></revision></page>
 1273+<page><id>214</id><title>Wikia RTE round-trip test 214</title><revision><id>214</id><text xml:space="preserve">{|
 1274+|''foo''
 1275+* bar
 1276+|}</text></revision></page>
 1277+<page><id>215</id><title>Wikia RTE round-trip test 215</title><revision><id>215</id><text xml:space="preserve">{|
 1278+|[[foo]]
 1279+* bar
 1280+|}</text></revision></page>
 1281+<page><id>216</id><title>Wikia RTE round-trip test 216</title><revision><id>216</id><text xml:space="preserve">{|
 1282+|''foo'' bar
 1283+* list item
 1284+|}</text></revision></page>
 1285+<page><id>217</id><title>Wikia RTE round-trip test 217</title><revision><id>217</id><text xml:space="preserve">{|
 1286+|[[foo]]&lt;br /&gt;bar
 1287+|}</text></revision></page>
 1288+<page><id>218</id><title>Wikia RTE round-trip test 218</title><revision><id>218</id><text xml:space="preserve">{|
 1289+|[[foo]]
 1290+&lt;br /&gt;bar
 1291+|}</text></revision></page>
 1292+<page><id>219</id><title>Wikia RTE round-trip test 219</title><revision><id>219</id><text xml:space="preserve">{|
 1293+| foo || || bar ||
 1294+|}</text></revision></page>
 1295+<page><id>220</id><title>Wikia RTE round-trip test 220</title><revision><id>220</id><text xml:space="preserve">&lt;gallery caption=&quot;Sample&quot; widths=&quot;200px&quot; heights=100 perrow=&quot;3&quot; captionalign=&quot;right&quot;&gt;
 1296+Spiderpig.jpg
 1297+&lt;/gallery&gt;</text></revision></page>
 1298+<page><id>221</id><title>Wikia RTE round-trip test 221</title><revision><id>221</id><text xml:space="preserve">{{{text}}}hgjhgjgh{{{text|test}}}
 1299+asas</text></revision></page>
 1300+<page><id>222</id><title>Wikia RTE round-trip test 222</title><revision><id>222</id><text xml:space="preserve">asdasdasdasd
 1301+
 1302+{{{text|Hmmm... This is a test}}}
 1303+asdasd</text></revision></page>
 1304+</mediawiki>
Property changes on: trunk/extensions/VisualEditor/tests/parser/wikia-rte-roundtrip-tests.xml
___________________________________________________________________
Added: svn:eol-style
11305 + native
Index: trunk/extensions/VisualEditor/tests/parser/roundtrip.js
@@ -0,0 +1,111 @@
 2+var fs = require('fs'),
 3+ jsDiff = require('diff'),
 4+ Worker = require('webworker').Worker,
 5+ DumpReader = require('./dumpReader.js').DumpReader;
 6+
 7+function runTests() {
 8+ function compareTest(a, b, msg) {
 9+ if (a === b) {
 10+ console.log('OK: ', msg);
 11+ return true;
 12+ } else {
 13+ console.log('MISMATCH: ', msg);
 14+ var patch = jsDiff.createPatch('wikitext.txt', a, b, 'before', 'after');
 15+ console.log(patch);
 16+ return false;
 17+ }
 18+ }
 19+
 20+ var state = {
 21+ doneReading: false,
 22+ revsIn: 0,
 23+ revsOut: 0
 24+ };
 25+ function checkState() {
 26+ var remaining = state.revsIn - state.revsOut;
 27+ console.log(remaining + ' in queue... ' + (state.revsOut + '/' + state.revsIn));
 28+ if (remaining == 0) {
 29+ console.log('are we done?', state.doneReading);
 30+ }
 31+ if (state.doneReading) {
 32+ if (remaining <= 0) {
 33+ console.log('done!');
 34+ process.exit(0);
 35+ }
 36+ } else {
 37+ if (remaining < queueLength && process.stdin.readable) {
 38+ process.stdin.resume();
 39+ }
 40+ }
 41+ }
 42+
 43+ var nWorkers = 8;
 44+ var queueLength = nWorkers * 2;
 45+ var workerDir = __dirname;
 46+ var workers = [];
 47+ workerJs = require('path').join(workerDir, 'worker.js');
 48+ for (var i = 0; i < nWorkers; i++) {
 49+ var worker = new Worker(workerJs);
 50+ worker.onerror = function(err) {
 51+ console.log('worker error', err);
 52+ process.exit(1);
 53+ };
 54+ worker.onclose = function() {
 55+ console.log('worker closed');
 56+ };
 57+ worker.onmessage = function(msg) {
 58+ var data = msg.data;
 59+ compareTest(data.expected, data.received, data.msg);
 60+ state.revsOut++;
 61+ checkState();
 62+ };
 63+ workers[i] = worker;
 64+ }
 65+ //var worker = require(workerJs);
 66+ function roundTripTest(text, msg) {
 67+ var worker = workers[state.revsIn % nWorkers];
 68+ state.revsIn++;
 69+ var remaining = state.revsIn - state.revsOut;
 70+ if (remaining >= queueLength) {
 71+ // Throttle the input until we catch up!
 72+ process.stdin.pause();
 73+ }
 74+ worker.postMessage({
 75+ action: 'roundTrip',
 76+ text: text,
 77+ msg: msg
 78+ });
 79+ }
 80+
 81+ // We need to tell the child process where its working directory is.
 82+ workers.forEach(function(worker) {
 83+ worker.postMessage({
 84+ action: 'init',
 85+ dir: workerDir
 86+ });
 87+ });
 88+
 89+ roundTripTest('A plain single line paragraph.', 'single-line paragraph');
 90+ //roundTripTest('A plain single line paragraph.\n\nA second paragraph after a blank.', 'two single-line paragraphs');
 91+
 92+ var reader = new DumpReader();
 93+ reader.on('end', function() {
 94+ console.log('done reading!');
 95+ state.doneReading = true;
 96+ checkState();
 97+ });
 98+ reader.on('error', function(err) {
 99+ console.log('error!', err);
 100+ process.exit(1);
 101+ });
 102+ reader.on('revision', function(revision) {
 103+ roundTripTest(revision.text, 'revision id ' + revision.id)
 104+ });
 105+ console.log('Reading!');
 106+ process.stdin.setEncoding('utf8');
 107+ process.stdin.resume();
 108+ reader.read(process.stdin);
 109+
 110+}
 111+
 112+runTests();
Property changes on: trunk/extensions/VisualEditor/tests/parser/roundtrip.js
___________________________________________________________________
Added: svn:eol-style
1113 + native
Index: trunk/extensions/VisualEditor/tests/parser/dumpReader.js
@@ -0,0 +1,132 @@
 2+var events = require('events'),
 3+ util = require('util'),
 4+ libxml = require('libxmljs'); // npm install libxmljs
 5+
 6+function DumpReader() {
 7+ events.EventEmitter.call(this);
 8+}
 9+
 10+util.inherits(DumpReader, events.EventEmitter);
 11+
 12+/**
 13+ * @param {Stream} stream input stream to read XML from
 14+ */
 15+DumpReader.prototype.read = function(stream) {
 16+ var self = this;
 17+ var complete = false;
 18+
 19+ var stack = [{}],
 20+ workspace = {},
 21+ buffer = '';
 22+
 23+ function flip(arr) {
 24+ var obj = {};
 25+ arr.forEach(function(val) {
 26+ obj[val] = true;
 27+ });
 28+ return obj;
 29+ }
 30+ var textNodes = flip(['id', 'text', 'title', 'minor', 'comment', 'username', 'timestamp']),
 31+ boolNodes = flip(['minor', 'redirect']),
 32+ ignoreNodes = flip(['mediawiki', 'siteinfo', 'upload', 'thread']);
 33+
 34+ var parser = new libxml.SaxPushParser(function(cb) {
 35+ cb.onStartElementNS(function(elem, attrs, prefix, uri, namespaces) {
 36+ if (elem in ignoreNodes) {
 37+ // ...
 38+ } else if (elem == 'page') {
 39+ stack = [];
 40+ workspace = {};
 41+ } else if (elem == 'revision') {
 42+ stack.push(workspace);
 43+ workspace = {
 44+ page: workspace
 45+ };
 46+ } else if (elem in textNodes || elem in boolNodes) {
 47+ buffer = '';
 48+ } else {
 49+ stack.push(workspace);
 50+ workspace = {};
 51+ }
 52+ });
 53+
 54+ cb.onEndElementNS(function(elem, prefix, uri) {
 55+ // ping something!
 56+ if (elem == 'mediawiki') {
 57+ self.complete = true;
 58+ stream.pause();
 59+ self.emit('end', {});
 60+ } else if (elem == 'page') {
 61+ self.emit('page', workspace);
 62+ workspace = stack.pop();
 63+ } else if (elem == 'revision') {
 64+ self.emit('revision', workspace);
 65+ workspace = stack.pop();
 66+ } else if (elem in textNodes) {
 67+ workspace[elem] = buffer;
 68+ } else if (elem in boolNodes) {
 69+ workspace[elem] = true;
 70+ } else {
 71+ var current = workspace;
 72+ workspace = stack.pop();
 73+ workspace[elem] = current;
 74+ }
 75+ });
 76+ cb.onCharacters(function(chars) {
 77+ buffer += chars;
 78+ });
 79+ cb.onCdata(function(cdata) {
 80+ buffer += cdata;
 81+ });
 82+ cb.onEndDocument(function() {
 83+ // This doesn't seem to run...?
 84+ self.complete = true;
 85+ stream.pause();
 86+ self.emit('end', {});
 87+ })
 88+ cb.onError(function(err) {
 89+ self.emit('error', err);
 90+ // Should we.... stop reading now or what?
 91+ });
 92+
 93+ // Now, start reading the file in :D
 94+ stream.on('data', function(buffer) {
 95+ parser.push(buffer); // @fixme does this want bytes or chars?
 96+ });
 97+ stream.on('end', function() {
 98+ if (!complete) {
 99+ // uh-oh!
 100+ //self.emit('error', 'End of file before end of XML stream.');
 101+ }
 102+ });
 103+ stream.on('error', function(err) {
 104+ self.emit('error', err);
 105+ });
 106+ });
 107+};
 108+
 109+
 110+module.exports.DumpReader = DumpReader;
 111+
 112+if (module === require.main) {
 113+ var reader = new DumpReader();
 114+ reader.on('end', function() {
 115+ console.log('done!');
 116+ process.exit();
 117+ });
 118+ reader.on('error', function(err) {
 119+ console.log('error!', err);
 120+ process.exit(1);
 121+ });
 122+ reader.on('page', function(page) {
 123+ console.log('page', page);
 124+ });
 125+ reader.on('revision', function(revision) {
 126+ revision.text = revision.text.substr(0, 40);
 127+ console.log('revision', revision);
 128+ });
 129+ console.log('Reading!');
 130+ process.stdin.setEncoding('utf8');
 131+ process.stdin.resume();
 132+ reader.read(process.stdin);
 133+}
Property changes on: trunk/extensions/VisualEditor/tests/parser/dumpReader.js
___________________________________________________________________
Added: svn:eol-style
1134 + native
Index: trunk/extensions/VisualEditor/tests/parser/worker.js
@@ -0,0 +1,53 @@
 2+var path = require('path');
 3+
 4+// Fake a worker-like interface so we can test it in-process
 5+// workers in node's webworker module don't seem to report errors very well.
 6+if (typeof module == "object") {
 7+ module.exports = {
 8+ postMessage: function(data) {
 9+ var msg = {data: JSON.parse(JSON.stringify(data))};
 10+ setTimeout(function() {
 11+ onmessage(msg);
 12+ }, 0);
 13+ },
 14+ onmessage: function(msg) {}
 15+ };
 16+
 17+ if (typeof postMessage === 'undefined') {
 18+ postMessage = function(data) {
 19+ var msg = {data: JSON.parse(JSON.stringify(data))};
 20+ setTimeout(function() {
 21+ module.exports.onmessage(msg)
 22+ }, 0);
 23+ }
 24+ }
 25+}
 26+
 27+// The worker context for some reason doesn't let us adjust globals,
 28+// so farming the good stuff out to a module which can.
 29+var didInit = false;
 30+var myWorker = {
 31+ postMessage: postMessage,
 32+ onmessage: function(msg) {
 33+ var data = msg.data;
 34+ if (data.action == 'init') {
 35+ if (didInit) {
 36+ throw new Error('second init request');
 37+ }
 38+ // Running as a worker in node.js we have to set the working directory
 39+ // or we won't be able to find our local files.
 40+ //
 41+ // It's a bit annoying. ;)
 42+ process.chdir(data.dir);
 43+ require(path.join(data.dir, 'roundtrip-test.js')).init(myWorker);
 44+ didInit = true;
 45+ } else {
 46+ throw new Error('Must init first!');
 47+ }
 48+ }
 49+};
 50+
 51+onmessage = function(msg) {
 52+ return myWorker.onmessage(msg);
 53+}
 54+
Property changes on: trunk/extensions/VisualEditor/tests/parser/worker.js
___________________________________________________________________
Added: svn:eol-style
155 + native
Index: trunk/extensions/VisualEditor/tests/parser/tests.html
@@ -0,0 +1,20 @@
 2+<!DOCTYPE html>
 3+<html>
 4+<head>
 5+
 6+<link rel="stylesheet" href="../modules/jquery.nodetree.css">
 7+
 8+<script src="../../../resources/jquery/jquery.js"></script>
 9+<script src="../../../resources/mediawiki/mediawiki.js"></script>
 10+
 11+<script src="../modules/jquery.nodetree.js"></script>
 12+<script src="../modules/mediawiki.parser.environment.js"></script>
 13+<script src="../modules/ext.parserPlayground.serializer.js"></script>
 14+
 15+<script src="expansionTest.js"></script>
 16+
 17+</head>
 18+
 19+<body>
 20+</body>
 21+</html>
Property changes on: trunk/extensions/VisualEditor/tests/parser/tests.html
___________________________________________________________________
Added: svn:eol-style
122 + native
Index: trunk/extensions/VisualEditor/tests/parser/parserTests.pegjs
@@ -0,0 +1,130 @@
 2+/**
 3+ * PEG.js grammar for reading MediaWiki parser tests files
 4+ * 2011-07-20 Brion Vibber <brion@pobox.com>
 5+ */
 6+
 7+testfile =
 8+ chunk+
 9+
 10+
 11+
 12+eol = "\n"
 13+
 14+whitespace = [ \t]+
 15+
 16+ws = whitespace
 17+
 18+rest_of_line = c:([^\n]*) eol
 19+{
 20+ return c.join('');
 21+}
 22+
 23+line = (!"!!") line:rest_of_line
 24+{
 25+ return line;
 26+}
 27+
 28+text = lines:line*
 29+{
 30+ return lines.join('\n');
 31+}
 32+
 33+chunk =
 34+ comment /
 35+ article /
 36+ test /
 37+ line /
 38+ hooks
 39+
 40+
 41+
 42+comment =
 43+ "#" text:rest_of_line
 44+{
 45+ return {
 46+ type: 'comment',
 47+ comment: text
 48+ }
 49+}
 50+
 51+empty =
 52+ eol /
 53+ ws eol
 54+{
 55+ return {
 56+ type: 'empty'
 57+ }
 58+}
 59+
 60+
 61+
 62+article =
 63+ start_article title:line start_text text:text end_article
 64+{
 65+ return {
 66+ type: 'article',
 67+ title: title,
 68+ text: text
 69+ }
 70+}
 71+
 72+start_article =
 73+ "!!" ws? "article" ws? eol
 74+
 75+start_text =
 76+ "!!" ws? "text" ws? eol
 77+
 78+end_article =
 79+ "!!" ws? "endarticle" ws? eol
 80+
 81+
 82+test =
 83+ start_test
 84+ title:text
 85+ sections:section*
 86+ end_test
 87+{
 88+ var test = {
 89+ type: 'test',
 90+ title: title
 91+ };
 92+ for (var i = 0; i < sections.length; i++) {
 93+ var section = sections[i];
 94+ test[section.name] = section.text;
 95+ }
 96+ return test;
 97+}
 98+
 99+section =
 100+ "!!" ws? (!"end") name:(c:[a-zA-Z0-9]+ { return c.join(''); }) rest_of_line
 101+ text:text
 102+{
 103+ return {
 104+ name: name,
 105+ text: text
 106+ };
 107+}
 108+
 109+/* the : is for a stray one, not sure it should be there */
 110+
 111+start_test =
 112+ "!!" ws? "test" ":"? ws? eol
 113+
 114+end_test =
 115+ "!!" ws? "end" ws? eol
 116+
 117+
 118+hooks =
 119+ start_hooks text:text end_hooks
 120+{
 121+ return {
 122+ type: 'hooks',
 123+ text: text
 124+ }
 125+}
 126+
 127+start_hooks =
 128+ "!!" ws? "hooks" ":"? ws? eol
 129+
 130+end_hooks =
 131+ "!!" ws? "endhooks" ws? eol
Property changes on: trunk/extensions/VisualEditor/tests/parser/parserTests.pegjs
___________________________________________________________________
Added: svn:eol-style
1132 + native
Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -0,0 +1,168 @@
 2+/**
 3+ * Initial parser tests runner for experimental JS parser
 4+ *
 5+ * This pulls all the parserTests.txt items and runs them through the JS
 6+ * parser and JS HTML renderer. Currently no comparison is done on output,
 7+ * as a direct string comparison won't be very encouraging. :)
 8+ *
 9+ * Needs smarter compare, as well as search-y helpers.
 10+ *
 11+ * 2011-07-20 <brion@pobox.com>
 12+ */
 13+
 14+var fs = require('fs'),
 15+ path = require('path');
 16+
 17+// @fixme wrap more or this setup in a common module
 18+
 19+// Fetch up some of our wacky parser bits...
 20+
 21+var basePath = path.join(path.dirname(path.dirname(process.cwd())), 'modules');
 22+function _require(filename) {
 23+ return require(path.join(basePath, filename));
 24+}
 25+
 26+function _import(filename, symbols) {
 27+ var module = _require(filename);
 28+ symbols.forEach(function(symbol) {
 29+ global[symbol] = module[symbol];
 30+ })
 31+}
 32+
 33+// For now most modules only need this for $.extend and $.each :)
 34+global.$ = require('jquery');
 35+
 36+// hack for renderer
 37+global.document = $('<div>')[0].ownerDocument;
 38+
 39+var pj = path.join;
 40+
 41+// Local CommonJS-friendly libs
 42+global.PEG = _require(pj('parser', 'lib.pegjs.js'));
 43+
 44+// Our code...
 45+_import(pj('parser', 'mediawiki.parser.peg.js'), ['PegParser']);
 46+_import(pj('parser', 'mediawiki.parser.environment.js'), ['MWParserEnvironment']);
 47+_import(pj('parser', 'ext.cite.taghook.ref.js'), ['MWRefTagHook']);
 48+
 49+// WikiDom and serializers
 50+_require(pj('es', 'es.js'));
 51+_require(pj('es', 'bases', 'es.EventEmitter.js'));
 52+_require(pj('es', 'bases', 'es.Document.js'));
 53+_require(pj('es', 'bases', 'es.Document.Serializer.js'));
 54+_require(pj('es', 'serializers', 'es.Document.HtmlSerializer.js'));
 55+_require(pj('es', 'serializers', 'es.Document.WikitextSerializer.js'));
 56+_require(pj('es', 'serializers', 'es.Document.JsonSerializer.js'));
 57+
 58+// Preload the grammar file...
 59+PegParser.src = fs.readFileSync(path.join(basePath, 'parser', 'pegParser.pegjs.txt'), 'utf8');
 60+
 61+var parser = new PegParser();
 62+
 63+var testFileName = '../../../../../tests/parser/parserTests.txt'; // default
 64+if (process.argv.length > 2) {
 65+ // hack :D
 66+ testFileName = process.argv[2];
 67+ console.log(testFileName);
 68+}
 69+
 70+try {
 71+ var testParser = PEG.buildParser(fs.readFileSync('parserTests.pegjs', 'utf8'));
 72+} catch (e) {
 73+ console.log(e);
 74+}
 75+
 76+var testFile = fs.readFileSync(testFileName, 'utf8');
 77+
 78+
 79+try {
 80+ var cases = testParser.parse(testFile);
 81+} catch (e) {
 82+ console.log(e);
 83+}
 84+
 85+var articles = {};
 86+
 87+function normalizeTitle(name) {
 88+ if (typeof name !== 'string') {
 89+ throw new Error('nooooooooo not a string');
 90+ }
 91+ name = name.replace(/[\s_]+/g, '_');
 92+ name = name.substr(0, 1).toUpperCase() + name.substr(1);
 93+ if (name == '') {
 94+ throw new Error('Invalid/empty title');
 95+ }
 96+ return name;
 97+}
 98+
 99+function fetchArticle(name) {
 100+ var norm = normalizeTitle(name);
 101+ if (norm in articles) {
 102+ return articles[norm];
 103+ }
 104+}
 105+
 106+function processArticle(item) {
 107+ var norm = normalizeTitle(item.title);
 108+ articles[norm] = item.text;
 109+}
 110+
 111+function nodeToHtml(node) {
 112+ return $('<div>').append(node).html();
 113+}
 114+
 115+function processTest(item) {
 116+ if (!('title' in item)) {
 117+ console.log(item);
 118+ throw new Error('Missing title from test case.');
 119+ }
 120+ if (!('input' in item)) {
 121+ console.log(item);
 122+ throw new Error('Missing input from test case ' + item.title);
 123+ }
 124+ if (!('result' in item)) {
 125+ console.log(item);
 126+ throw new Error('Missing input from test case ' + item.title);
 127+ }
 128+ console.log(item.title);
 129+ console.log("INPUT:");
 130+ console.log(item.input);
 131+
 132+ parser.parseToTree(item.input + "\n", function(tree, err) {
 133+ console.log('INPUT:');
 134+ console.log(item.input + "\n");
 135+ if (err) {
 136+ console.log('PARSE FAIL', err);
 137+ } else {
 138+ var environment = new MWParserEnvironment({
 139+ tagHooks: {
 140+ 'ref': MWRefTagHook,
 141+ 'references': MWReferencesTagHook
 142+ }
 143+ });
 144+ var renderer = new es.Document.HtmlSerializer(environment);
 145+ // XXX: hack
 146+ tree.blocks = tree.content;
 147+ var res = renderer.serializeDocument(tree, false);
 148+ if (err) {
 149+ console.log('RENDER FAIL', err);
 150+ } else {
 151+ console.log('EXPECTED:');
 152+ console.log(item.result + "\n");
 153+
 154+ console.log('RENDERED:');
 155+ console.log(res + "\n");
 156+ }
 157+ }
 158+ });
 159+}
 160+
 161+cases.forEach(function(item) {
 162+ if (typeof item == 'object') {
 163+ if (item.type == 'article') {
 164+ processArticle(item);
 165+ } else if (item.type == 'test') {
 166+ processTest(item);
 167+ }
 168+ }
 169+});
Property changes on: trunk/extensions/VisualEditor/tests/parser/parserTests.js
___________________________________________________________________
Added: svn:eol-style
1170 + native
Index: trunk/extensions/VisualEditor/tests/parser/README
@@ -0,0 +1,9 @@
 2+Work in progress. :)
 3+
 4+Batch-testing tools loading the parsing code into node.js, and going through a MediaWiki XML export dump to run round-trip tests over it. Currently not much will succeed as there's bad handling of newlines. ;)
 5+
 6+Need npm modules:
 7+* jquery
 8+* diff
 9+* libxmljs (requires native compilation)
 10+* webworker
Property changes on: trunk/extensions/VisualEditor/tests/parser/README
___________________________________________________________________
Added: svn:eol-style
111 + native
Index: trunk/extensions/VisualEditor/tests/parser/roundtrip-test.js
@@ -0,0 +1,62 @@
 2+module.exports.init = function(worker) {
 3+ var fs = require('fs'),
 4+ path = require('path');
 5+
 6+ // Fetch up some of our wacky parser bits...
 7+
 8+ //var basePath = '../modules/';
 9+ var basePath = path.join(path.dirname(process.cwd()), 'modules');
 10+ function _require(filename) {
 11+ return require(path.join(basePath, filename));
 12+ }
 13+
 14+ function _import(filename, symbols) {
 15+ var module = _require(filename);
 16+ symbols.forEach(function(symbol) {
 17+ global[symbol] = module[symbol];
 18+ })
 19+ }
 20+
 21+ // For now most modules only need this for $.extend and $.each :)
 22+ global.$ = require('jquery');
 23+
 24+ // Local CommonJS-friendly libs
 25+ global.PEG = _require('lib.pegjs.js');
 26+
 27+ // Our code...
 28+ _import('ext.parserPlayground.serializer.js', ['MWTreeSerializer']);
 29+ _import('ext.parserPlayground.pegParser.js', ['PegParser']);
 30+
 31+ // Preload the grammar file...
 32+ PegParser.src = fs.readFileSync(path.join(basePath, 'pegParser.pegjs.txt'), 'utf8');
 33+
 34+ var parser = new PegParser(),
 35+ serializer = new MWTreeSerializer();
 36+
 37+ function sendResult(expected, received, msg) {
 38+ worker.postMessage({
 39+ expected: expected,
 40+ received: received,
 41+ msg: msg
 42+ });
 43+ }
 44+
 45+ roundTripTest = function(text, msg) {
 46+ parser.parseToTree(text, function(tree, err) {
 47+ if (err) throw new Error(err);
 48+ serializer.treeToSource(tree, function(newText, err) {
 49+ if (err) throw new Error(err);
 50+ sendResult(text, newText, msg);
 51+ })
 52+ })
 53+ }
 54+
 55+ worker.onmessage = function(msg) {
 56+ var data = msg.data;
 57+ if (data.action == 'roundTrip') {
 58+ roundTripTest(data.text, data.msg);
 59+ } else {
 60+ throw new Error('unknown action ' + data.action);
 61+ }
 62+ }
 63+};
Property changes on: trunk/extensions/VisualEditor/tests/parser/roundtrip-test.js
___________________________________________________________________
Added: svn:eol-style
164 + native
Index: trunk/extensions/VisualEditor/modules/es/es.js
@@ -3,7 +3,7 @@
44 *
55 * All classes and functions will be attached to this object to keep the global namespace clean.
66 */
7 -var es = {};
 7+es = {};
88
99 /* Functions */
1010
Index: trunk/extensions/VisualEditor/modules/es/serializers/es.Document.WikitextSerializer.js
@@ -172,4 +172,4 @@
173173
174174 /* Inheritance */
175175
176 -es.extend( es.Document.WikitextSerializer, es.Document.Serializer );
 176+es.extendClass( es.Document.WikitextSerializer, es.Document.Serializer );
Index: trunk/extensions/VisualEditor/modules/es/serializers/es.Document.JsonSerializer.js
@@ -117,4 +117,4 @@
118118
119119 /* Inheritance */
120120
121 -es.extend( es.Document.JsonSerializer, es.Document.Serializer );
 121+es.extendClass( es.Document.JsonSerializer, es.Document.Serializer );
Index: trunk/extensions/VisualEditor/modules/es/serializers/es.Document.HtmlSerializer.js
@@ -201,4 +201,4 @@
202202
203203 /* Inheritance */
204204
205 -es.extend( es.Document.HtmlSerializer, es.Document.Serializer );
 205+es.extendClass( es.Document.HtmlSerializer, es.Document.Serializer );
Index: trunk/extensions/VisualEditor/modules/es/bases/es.Document.js
@@ -0,0 +1,82 @@
 2+/**
 3+ * Ordered collection of blocks.
 4+ *
 5+ * @class
 6+ * @constructor
 7+ * @extends {es.EventEmitter}
 8+ * @param blocks {Array} List of blocks
 9+ * @property blocks {Array}
 10+ * @property width {Integer}
 11+ */
 12+es.Document = function( blocks ) {
 13+ es.DomContainer.call( this, 'document', 'blocks', blocks );
 14+ this.width = null;
 15+};
 16+
 17+/* Static Members */
 18+
 19+/**
 20+ * List of registered document serializers.
 21+ */
 22+es.Document.serializers = {};
 23+
 24+/* Static Methods */
 25+
 26+/**
 27+ * Creates new es.Document from a WikiDom Document object
 28+ *
 29+ * @method
 30+ * @param {Object} WikiDom document object
 31+ * @returns {es.Document} EditSurface document object
 32+ */
 33+es.Document.newFromWikiDomDocument = function( wikidomDocument ) {
 34+ var blocks = [];
 35+ if ( $.isArray( wikidomDocument.blocks ) ) {
 36+ for ( var i = 0; i < wikidomDocument.blocks.length; i++ ) {
 37+ blocks.push( es.Block.newFromWikiDomBlock( wikidomDocument.blocks[i] ) );
 38+ }
 39+ }
 40+ return new es.Document( blocks );
 41+};
 42+
 43+/* Methods */
 44+
 45+es.Document.prototype.serialize = function( serializer, context, options ) {
 46+ if ( serializer in es.Document.serializers ) {
 47+ return es.Document.serializers[serializer]( this.getWikiDomDocument(), context, options );
 48+ }
 49+};
 50+
 51+es.Document.prototype.getSerializers = function() {
 52+ return es.Document.serializers;
 53+};
 54+
 55+/**
 56+ * Forces all blocks in the document to render.
 57+ *
 58+ * @method
 59+ */
 60+es.Document.prototype.renderBlocks = function() {
 61+ // Bypass rendering when width has not changed
 62+ var width = this.$.innerWidth();
 63+ if ( this.width === width ) {
 64+ return;
 65+ }
 66+ this.width = width;
 67+ // Render blocks
 68+ for ( var i = 0; i < this.blocks.length; i++ ) {
 69+ this.blocks[i].renderContent();
 70+ }
 71+};
 72+
 73+es.Document.prototype.getWikiDomDocument = function() {
 74+ var wikidom = { blocks: [ ] };
 75+ for ( var i = 0; i < this.blocks.length; i++ ) {
 76+ wikidom.blocks.push( this.blocks[i].getWikiDom() );
 77+ }
 78+ return wikidom;
 79+};
 80+
 81+/* Inheritance */
 82+
 83+$.extend( es, es.Document, es.DomContainer );
Property changes on: trunk/extensions/VisualEditor/modules/es/bases/es.Document.js
___________________________________________________________________
Added: svn:eol-style
184 + native
Added: svn:mime-type
285 + text/plain
Index: trunk/extensions/VisualEditor/modules/es/bases/es.Document.Serializer.js
@@ -0,0 +1,69 @@
 2+/**
 3+ * Creates content serializer.
 4+ *
 5+ * Base object for all serializers, providing basic shared functionality and stubs for required
 6+ * implementations.
 7+ *
 8+ * @class
 9+ * @constructor
 10+ * @param context {es.WikiContext} Context of the wiki the document is a part of
 11+ * @property context {es.WikiContext} Context of the wiki the document is a part of
 12+ */
 13+es.Document.Serializer = function( context ) {
 14+ this.context = context;
 15+};
 16+
 17+/* Static Methods */
 18+
 19+es.Document.Serializer.repeatString = function( pattern, count ) {
 20+ if ( count < 1 ) {
 21+ return '';
 22+ }
 23+ var result = '';
 24+ while ( count > 0 ) {
 25+ if ( count & 1 ) { result += pattern; }
 26+ count >>= 1;
 27+ pattern += pattern;
 28+ }
 29+ return result;
 30+};
 31+
 32+es.Document.Serializer.escapeXmlText = function( text ) {
 33+ return text
 34+ .replace( /&/g, '&amp;' )
 35+ .replace( /</g, '&lt;' )
 36+ .replace( />/g, '&gt;' )
 37+ .replace( /"/g, '&quot;' )
 38+ .replace( /'/g, '&#039;' );
 39+};
 40+
 41+es.Document.Serializer.buildXmlAttributes = function( attributes, prespace ) {
 42+ var attr = [];
 43+ var name;
 44+ if ( attributes ) {
 45+ for ( name in attributes ) {
 46+ attr.push( name + '="' + attributes[name] + '"' );
 47+ }
 48+ }
 49+ return ( prespace && attr.length ? ' ' : '' ) + attr.join( ' ' );
 50+};
 51+
 52+es.Document.Serializer.buildXmlOpeningTag = function( tag, attributes ) {
 53+ return '<' + tag + es.Document.Serializer.buildXmlAttributes( attributes, true ) + '>';
 54+};
 55+
 56+es.Document.Serializer.buildXmlClosingTag = function( tag ) {
 57+ return '</' + tag + '>';
 58+};
 59+
 60+es.Document.Serializer.buildXmlTag = function( tag, attributes, value, escape ) {
 61+ if ( value === false ) {
 62+ return '<' + tag + es.Document.Serializer.buildXmlAttributes( attributes, true ) + ' />';
 63+ } else {
 64+ if ( escape ) {
 65+ value = wiki.util.xml.esc( value );
 66+ }
 67+ return '<' + tag + es.Document.Serializer.buildXmlAttributes( attributes, true ) + '>' +
 68+ value + '</' + tag + '>';
 69+ }
 70+};
Property changes on: trunk/extensions/VisualEditor/modules/es/bases/es.Document.Serializer.js
___________________________________________________________________
Added: svn:eol-style
171 + native
Added: svn:mime-type
272 + text/plain
Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt
@@ -93,7 +93,7 @@
9494 else
9595 es.push(ei);
9696 });
97 - //dp(print_r(es));
 97+ dp(print_r(es));
9898 return {
9999 type: 'page',
100100 content: es
@@ -180,7 +180,7 @@
181181
182182 h1 = '=' c:heading_text '=' newline {
183183 return {
184 - type: 'h',
 184+ type: 'heading',
185185 level: 1,
186186 text: c
187187 }
@@ -188,7 +188,7 @@
189189
190190 h2 = '==' c:heading_text '==' newline {
191191 return {
192 - type: 'h',
 192+ type: 'heading',
193193 level: 2,
194194 text: c
195195 }
@@ -196,7 +196,7 @@
197197
198198 h3 = '===' c:heading_text '===' newline {
199199 return {
200 - type: 'h',
 200+ type: 'heading',
201201 level: 3,
202202 text: c
203203 }
@@ -204,7 +204,7 @@
205205
206206 h4 = '====' c:heading_text '====' newline {
207207 return {
208 - type: 'h',
 208+ type: 'heading',
209209 level: 4,
210210 text: c
211211 }
@@ -212,7 +212,7 @@
213213
214214 h5 = '=====' c:heading_text '=====' newline {
215215 return {
216 - type: 'h',
 216+ type: 'heading',
217217 level: 5,
218218 text: c
219219 }
@@ -220,7 +220,7 @@
221221
222222 h6 = '======' c:heading_text '======' newline {
223223 return {
224 - type: 'h',
 224+ type: 'heading',
225225 level: 6,
226226 text: c
227227 }
@@ -236,7 +236,7 @@
237237 = newline { return {type: 'br'} }
238238
239239 para
240 - = c:inlineline newline { return {type: 'para', content: c } } /
 240+ = c:inlineline newline { return {type: 'paragraph', content: c } } /
241241 c:anyline
242242
243243 inline

Status & tagging log