Browse code

autoclose valid tags

devnewton authored on 21/06/2016 21:23:35
Showing 3 changed files
... ...
@@ -11,7 +11,7 @@ function convert() {
11 11
 convertButton.addEventListener('click', convert);
12 12
 
13 13
 function init() {
14
-	inputArea.value = '>o_/ 22:23:56 #5766f86ae4b00e368dfab8a3 [:bondour] 2016/06/19#10:22:01 les <b>moules<</b> \\_o< https://sauf.ca http://totoz.eu/ ftp://ftp.fr.debian.org/ <a><i> <a nofollow="plop" href="http://linuxfr.org"> <a href="http://linuxfr.org" nofollow target="_blank">plop</a>';
14
+	inputArea.value = '>o_/ 22:23:56 #5766f86ae4b00e368dfab8a3 [:bondour] 2016/06/19#10:22:01 les <b>moules<</b> \\_o< https://sauf.ca http://totoz.eu/ ftp://ftp.fr.debian.org/ <a><i> <a nofollow="plop" href="http://linuxfr.org"> <a href="http://linuxfr.org" nofollow target="_blank">plop</a> <b><i>pas fermé</u>';
15 15
 	convert();
16 16
 }
17 17
 document.readyState === "interactive" || document.readyState === "complete" ? init() : document.addEventListener("DOMContentLoaded", init);
... ...
@@ -36,7 +36,13 @@ p2c2 = (function() {
36 36
         peg$startRuleFunctions = { post: peg$parsepost },
37 37
         peg$startRuleFunction  = peg$parsepost,
38 38
 
39
-        peg$c0 = function(items) { return items.join(""); },
39
+        peg$c0 = function(items) {
40
+         	var result = items.join("");
41
+            while(p2c2.tagStack.length > 0) {
42
+            	result += "</" + p2c2.tagStack.pop() + ">";
43
+            }
44
+            return result;
45
+         },
40 46
         peg$c1 = { type: "any", description: "any character" },
41 47
         peg$c2 = "http",
42 48
         peg$c3 = { type: "literal", value: "http", description: "\"http\"" },
... ...
@@ -60,94 +66,115 @@ p2c2 = (function() {
60 66
         peg$c21 = function() {return '<canard/>';},
61 67
         peg$c22 = /^[o0\xF4\xB0\xF8\xF2\xF3@]/,
62 68
         peg$c23 = { type: "class", value: "[o0\xF4\xB0\xF8\xF2\xF3@]", description: "[o0\xF4\xB0\xF8\xF2\xF3@]" },
63
-        peg$c24 = "b",
64
-        peg$c25 = { type: "literal", value: "b", description: "\"b\"" },
65
-        peg$c26 = "i",
66
-        peg$c27 = { type: "literal", value: "i", description: "\"i\"" },
67
-        peg$c28 = "u",
68
-        peg$c29 = { type: "literal", value: "u", description: "\"u\"" },
69
-        peg$c30 = "tt",
70
-        peg$c31 = { type: "literal", value: "tt", description: "\"tt\"" },
71
-        peg$c32 = "</",
72
-        peg$c33 = { type: "literal", value: "</", description: "\"</\"" },
73
-        peg$c34 = function() { return ""; },
74
-        peg$c35 = /^[A-Za-z]/,
75
-        peg$c36 = { type: "class", value: "[A-Za-z]", description: "[A-Za-z]" },
76
-        peg$c37 = /^[^>]/,
77
-        peg$c38 = { type: "class", value: "[^>]", description: "[^>]" },
78
-        peg$c39 = "<a",
79
-        peg$c40 = { type: "literal", value: "<a", description: "\"<a\"" },
80
-        peg$c41 = /^[^<]/,
81
-        peg$c42 = { type: "class", value: "[^<]", description: "[^<]" },
82
-        peg$c43 = "</a>",
83
-        peg$c44 = { type: "literal", value: "</a>", description: "\"</a>\"" },
84
-        peg$c45 = function(attributes) { 
69
+        peg$c24 = function(tag) {
70
+         	p2c2.tagStack.push(tag);
71
+            console.log("push " + tag);
72
+         	return "<" + tag + ">";
73
+         },
74
+        peg$c25 = "</",
75
+        peg$c26 = { type: "literal", value: "</", description: "\"</\"" },
76
+        peg$c27 = function(tag) {
77
+         	var result = "";
78
+         	for(;;) {
79
+              var poppedTag = p2c2.tagStack.pop();
80
+              if(poppedTag == undefined) {
81
+              	break;
82
+              }
83
+              if( poppedTag == tag) {
84
+              	result += "</" + tag + ">";
85
+                break;
86
+              } else {
87
+              	result += "</" + poppedTag + ">";
88
+              }
89
+            }
90
+            return result;
91
+         },
92
+        peg$c28 = "b",
93
+        peg$c29 = { type: "literal", value: "b", description: "\"b\"" },
94
+        peg$c30 = "i",
95
+        peg$c31 = { type: "literal", value: "i", description: "\"i\"" },
96
+        peg$c32 = "u",
97
+        peg$c33 = { type: "literal", value: "u", description: "\"u\"" },
98
+        peg$c34 = "tt",
99
+        peg$c35 = { type: "literal", value: "tt", description: "\"tt\"" },
100
+        peg$c36 = function() { return ""; },
101
+        peg$c37 = /^[A-Za-z]/,
102
+        peg$c38 = { type: "class", value: "[A-Za-z]", description: "[A-Za-z]" },
103
+        peg$c39 = /^[^>]/,
104
+        peg$c40 = { type: "class", value: "[^>]", description: "[^>]" },
105
+        peg$c41 = "<a",
106
+        peg$c42 = { type: "literal", value: "<a", description: "\"<a\"" },
107
+        peg$c43 = /^[^<]/,
108
+        peg$c44 = { type: "class", value: "[^<]", description: "[^<]" },
109
+        peg$c45 = "</a>",
110
+        peg$c46 = { type: "literal", value: "</a>", description: "\"</a>\"" },
111
+        peg$c47 = function(attributes) { 
85 112
            if(attributes.href) {
86 113
               return "<url>" + attributes.href + "</url>";
87 114
            }
88 115
          },
89
-        peg$c46 = " ",
90
-        peg$c47 = { type: "literal", value: " ", description: "\" \"" },
91
-        peg$c48 = function(separator, attribute) { return attribute;},
92
-        peg$c49 = function(attributes) {  var result = {};
116
+        peg$c48 = " ",
117
+        peg$c49 = { type: "literal", value: " ", description: "\" \"" },
118
+        peg$c50 = function(separator, attribute) { return attribute;},
119
+        peg$c51 = function(attributes) {  var result = {};
93 120
          	for(var a in attributes) {
94 121
             	result[attributes[a].name] = attributes[a].value;
95 122
             }
96 123
          	return result;
97 124
          },
98
-        peg$c50 = /^[a-z]/,
99
-        peg$c51 = { type: "class", value: "[a-z]", description: "[a-z]" },
100
-        peg$c52 = "=\"",
101
-        peg$c53 = { type: "literal", value: "=\"", description: "\"=\\\"\"" },
102
-        peg$c54 = /^[^"]/,
103
-        peg$c55 = { type: "class", value: "[^\"]", description: "[^\"]" },
104
-        peg$c56 = "\"",
105
-        peg$c57 = { type: "literal", value: "\"", description: "\"\\\"\"" },
106
-        peg$c58 = function(name, value) {return value;},
107
-        peg$c59 = function(name, value) {return { name: name, value: value}},
108
-        peg$c60 = function(norloge) { return '<norloge>' + norloge +'</norloge>'},
109
-        peg$c61 = "/",
110
-        peg$c62 = { type: "literal", value: "/", description: "\"/\"" },
111
-        peg$c63 = function(y, ln) { return y + "/" + ln; },
112
-        peg$c64 = /^[0-9]/,
113
-        peg$c65 = { type: "class", value: "[0-9]", description: "[0-9]" },
114
-        peg$c66 = function(digits) { return digits.join(""); },
115
-        peg$c67 = "#",
116
-        peg$c68 = { type: "literal", value: "#", description: "\"#\"" },
117
-        peg$c69 = function(m, d, nn) { return m + "/" + d + "#" + nn; },
118
-        peg$c70 = /^[0-1]/,
119
-        peg$c71 = { type: "class", value: "[0-1]", description: "[0-1]" },
120
-        peg$c72 = function(first, last) { return first + last; },
121
-        peg$c73 = /^[0-3]/,
122
-        peg$c74 = { type: "class", value: "[0-3]", description: "[0-3]" },
123
-        peg$c75 = ":",
124
-        peg$c76 = { type: "literal", value: ":", description: "\":\"" },
125
-        peg$c77 = function(sn, s) { return sn + ":" + s; },
126
-        peg$c78 = function(h, m) { return h + ":" + m; },
127
-        peg$c79 = /^[0-2]/,
128
-        peg$c80 = { type: "class", value: "[0-2]", description: "[0-2]" },
129
-        peg$c81 = /^[0-5]/,
130
-        peg$c82 = { type: "class", value: "[0-5]", description: "[0-5]" },
131
-        peg$c83 = /^[a-zA-Z0-9_]/,
132
-        peg$c84 = { type: "class", value: "[a-zA-Z0-9_]", description: "[a-zA-Z0-9_]" },
133
-        peg$c85 = function(chars) { var norlogeId = chars.join("");
125
+        peg$c52 = /^[a-z]/,
126
+        peg$c53 = { type: "class", value: "[a-z]", description: "[a-z]" },
127
+        peg$c54 = "=\"",
128
+        peg$c55 = { type: "literal", value: "=\"", description: "\"=\\\"\"" },
129
+        peg$c56 = /^[^"]/,
130
+        peg$c57 = { type: "class", value: "[^\"]", description: "[^\"]" },
131
+        peg$c58 = "\"",
132
+        peg$c59 = { type: "literal", value: "\"", description: "\"\\\"\"" },
133
+        peg$c60 = function(name, value) {return value;},
134
+        peg$c61 = function(name, value) {return { name: name, value: value}},
135
+        peg$c62 = function(norloge) { return '<norloge>' + norloge +'</norloge>'},
136
+        peg$c63 = "/",
137
+        peg$c64 = { type: "literal", value: "/", description: "\"/\"" },
138
+        peg$c65 = function(y, ln) { return y + "/" + ln; },
139
+        peg$c66 = /^[0-9]/,
140
+        peg$c67 = { type: "class", value: "[0-9]", description: "[0-9]" },
141
+        peg$c68 = function(digits) { return digits.join(""); },
142
+        peg$c69 = "#",
143
+        peg$c70 = { type: "literal", value: "#", description: "\"#\"" },
144
+        peg$c71 = function(m, d, nn) { return m + "/" + d + "#" + nn; },
145
+        peg$c72 = /^[0-1]/,
146
+        peg$c73 = { type: "class", value: "[0-1]", description: "[0-1]" },
147
+        peg$c74 = function(first, last) { return first + last; },
148
+        peg$c75 = /^[0-3]/,
149
+        peg$c76 = { type: "class", value: "[0-3]", description: "[0-3]" },
150
+        peg$c77 = ":",
151
+        peg$c78 = { type: "literal", value: ":", description: "\":\"" },
152
+        peg$c79 = function(sn, s) { return sn + ":" + s; },
153
+        peg$c80 = function(h, m) { return h + ":" + m; },
154
+        peg$c81 = /^[0-2]/,
155
+        peg$c82 = { type: "class", value: "[0-2]", description: "[0-2]" },
156
+        peg$c83 = /^[0-5]/,
157
+        peg$c84 = { type: "class", value: "[0-5]", description: "[0-5]" },
158
+        peg$c85 = /^[a-zA-Z0-9_]/,
159
+        peg$c86 = { type: "class", value: "[a-zA-Z0-9_]", description: "[a-zA-Z0-9_]" },
160
+        peg$c87 = function(chars) { var norlogeId = chars.join("");
134 161
            return '<norloge-id>#' + norlogeId + '</norloge-id>';
135 162
            },
136
-        peg$c86 = /^[a-zA-Z0-9\-_]/,
137
-        peg$c87 = { type: "class", value: "[a-zA-Z0-9-_]", description: "[a-zA-Z0-9-_]" },
138
-        peg$c88 = /^[<[]/,
139
-        peg$c89 = { type: "class", value: "[<[]", description: "[<[]" },
140
-        peg$c90 = function(bigorno) { return [].concat('<bigorno>', bigorno,'</bigorno>').join("")},
141
-        peg$c91 = "[:",
142
-        peg$c92 = { type: "literal", value: "[:", description: "\"[:\"" },
143
-        peg$c93 = /^[^\]]/,
144
-        peg$c94 = { type: "class", value: "[^\\]]", description: "[^\\]]" },
145
-        peg$c95 = "]",
146
-        peg$c96 = { type: "literal", value: "]", description: "\"]\"" },
147
-        peg$c97 = function(first, totoz, third) { var totozId = totoz.join(""); 
163
+        peg$c88 = /^[a-zA-Z0-9\-_]/,
164
+        peg$c89 = { type: "class", value: "[a-zA-Z0-9-_]", description: "[a-zA-Z0-9-_]" },
165
+        peg$c90 = /^[<[]/,
166
+        peg$c91 = { type: "class", value: "[<[]", description: "[<[]" },
167
+        peg$c92 = function(bigorno) { return [].concat('<bigorno>', bigorno,'</bigorno>').join("")},
168
+        peg$c93 = "[:",
169
+        peg$c94 = { type: "literal", value: "[:", description: "\"[:\"" },
170
+        peg$c95 = /^[^\]]/,
171
+        peg$c96 = { type: "class", value: "[^\\]]", description: "[^\\]]" },
172
+        peg$c97 = "]",
173
+        peg$c98 = { type: "literal", value: "]", description: "\"]\"" },
174
+        peg$c99 = function(first, totoz, third) { var totozId = totoz.join(""); 
148 175
           return '<totoz>' + totozId + '</totoz>'; },
149
-        peg$c98 = /^[ \t\r\n]/,
150
-        peg$c99 = { type: "class", value: "[ \\t\\r\\n]", description: "[ \\t\\r\\n]" },
176
+        peg$c100 = /^[ \t\r\n]/,
177
+        peg$c101 = { type: "class", value: "[ \\t\\r\\n]", description: "[ \\t\\r\\n]" },
151 178
 
152 179
         peg$currPos          = 0,
153 180
         peg$savedPos         = 0,
... ...
@@ -592,49 +619,104 @@ p2c2 = (function() {
592 619
     }
593 620
 
594 621
     function peg$parseopentag() {
595
-      var s0, s1, s2, s3, s4;
622
+      var s0;
623
+
624
+      s0 = peg$parsevalidOpenTag();
625
+      if (s0 === peg$FAILED) {
626
+        s0 = peg$parseinvalidOpenTag();
627
+      }
628
+
629
+      return s0;
630
+    }
631
+
632
+    function peg$parsevalidOpenTag() {
633
+      var s0, s1, s2, s3;
596 634
 
597 635
       s0 = peg$currPos;
598
-      s1 = peg$currPos;
599 636
       if (input.charCodeAt(peg$currPos) === 60) {
600
-        s2 = peg$c15;
637
+        s1 = peg$c15;
601 638
         peg$currPos++;
602 639
       } else {
603
-        s2 = peg$FAILED;
640
+        s1 = peg$FAILED;
604 641
         if (peg$silentFails === 0) { peg$fail(peg$c16); }
605 642
       }
606
-      if (s2 !== peg$FAILED) {
607
-        s3 = peg$parsevalidFormatTag();
608
-        if (s3 !== peg$FAILED) {
643
+      if (s1 !== peg$FAILED) {
644
+        s2 = peg$parsevalidFormatTag();
645
+        if (s2 !== peg$FAILED) {
609 646
           if (input.charCodeAt(peg$currPos) === 62) {
610
-            s4 = peg$c17;
647
+            s3 = peg$c17;
611 648
             peg$currPos++;
612 649
           } else {
613
-            s4 = peg$FAILED;
650
+            s3 = peg$FAILED;
614 651
             if (peg$silentFails === 0) { peg$fail(peg$c18); }
615 652
           }
616
-          if (s4 !== peg$FAILED) {
617
-            s2 = [s2, s3, s4];
618
-            s1 = s2;
653
+          if (s3 !== peg$FAILED) {
654
+            peg$savedPos = s0;
655
+            s1 = peg$c24(s2);
656
+            s0 = s1;
619 657
           } else {
620
-            peg$currPos = s1;
621
-            s1 = peg$FAILED;
658
+            peg$currPos = s0;
659
+            s0 = peg$FAILED;
622 660
           }
623 661
         } else {
624
-          peg$currPos = s1;
625
-          s1 = peg$FAILED;
662
+          peg$currPos = s0;
663
+          s0 = peg$FAILED;
626 664
         }
627 665
       } else {
628
-        peg$currPos = s1;
666
+        peg$currPos = s0;
667
+        s0 = peg$FAILED;
668
+      }
669
+
670
+      return s0;
671
+    }
672
+
673
+    function peg$parseclosetag() {
674
+      var s0;
675
+
676
+      s0 = peg$parsevalidCloseTag();
677
+      if (s0 === peg$FAILED) {
678
+        s0 = peg$parseinvalidCloseTag();
679
+      }
680
+
681
+      return s0;
682
+    }
683
+
684
+    function peg$parsevalidCloseTag() {
685
+      var s0, s1, s2, s3;
686
+
687
+      s0 = peg$currPos;
688
+      if (input.substr(peg$currPos, 2) === peg$c25) {
689
+        s1 = peg$c25;
690
+        peg$currPos += 2;
691
+      } else {
629 692
         s1 = peg$FAILED;
693
+        if (peg$silentFails === 0) { peg$fail(peg$c26); }
630 694
       }
631 695
       if (s1 !== peg$FAILED) {
632
-        s0 = input.substring(s0, peg$currPos);
696
+        s2 = peg$parsevalidFormatTag();
697
+        if (s2 !== peg$FAILED) {
698
+          if (input.charCodeAt(peg$currPos) === 62) {
699
+            s3 = peg$c17;
700
+            peg$currPos++;
701
+          } else {
702
+            s3 = peg$FAILED;
703
+            if (peg$silentFails === 0) { peg$fail(peg$c18); }
704
+          }
705
+          if (s3 !== peg$FAILED) {
706
+            peg$savedPos = s0;
707
+            s1 = peg$c27(s2);
708
+            s0 = s1;
709
+          } else {
710
+            peg$currPos = s0;
711
+            s0 = peg$FAILED;
712
+          }
713
+        } else {
714
+          peg$currPos = s0;
715
+          s0 = peg$FAILED;
716
+        }
633 717
       } else {
634
-        s0 = s1;
635
-      }
636
-      if (s0 === peg$FAILED) {
637
-        s0 = peg$parseinvalidOpenTag();
718
+        peg$currPos = s0;
719
+        s0 = peg$FAILED;
638 720
       }
639 721
 
640 722
       return s0;
... ...
@@ -644,19 +726,19 @@ p2c2 = (function() {
644 726
       var s0;
645 727
 
646 728
       if (input.charCodeAt(peg$currPos) === 98) {
647
-        s0 = peg$c24;
729
+        s0 = peg$c28;
648 730
         peg$currPos++;
649 731
       } else {
650 732
         s0 = peg$FAILED;
651
-        if (peg$silentFails === 0) { peg$fail(peg$c25); }
733
+        if (peg$silentFails === 0) { peg$fail(peg$c29); }
652 734
       }
653 735
       if (s0 === peg$FAILED) {
654 736
         if (input.charCodeAt(peg$currPos) === 105) {
655
-          s0 = peg$c26;
737
+          s0 = peg$c30;
656 738
           peg$currPos++;
657 739
         } else {
658 740
           s0 = peg$FAILED;
659
-          if (peg$silentFails === 0) { peg$fail(peg$c27); }
741
+          if (peg$silentFails === 0) { peg$fail(peg$c31); }
660 742
         }
661 743
         if (s0 === peg$FAILED) {
662 744
           if (input.charCodeAt(peg$currPos) === 115) {
... ...
@@ -668,19 +750,19 @@ p2c2 = (function() {
668 750
           }
669 751
           if (s0 === peg$FAILED) {
670 752
             if (input.charCodeAt(peg$currPos) === 117) {
671
-              s0 = peg$c28;
753
+              s0 = peg$c32;
672 754
               peg$currPos++;
673 755
             } else {
674 756
               s0 = peg$FAILED;
675
-              if (peg$silentFails === 0) { peg$fail(peg$c29); }
757
+              if (peg$silentFails === 0) { peg$fail(peg$c33); }
676 758
             }
677 759
             if (s0 === peg$FAILED) {
678
-              if (input.substr(peg$currPos, 2) === peg$c30) {
679
-                s0 = peg$c30;
760
+              if (input.substr(peg$currPos, 2) === peg$c34) {
761
+                s0 = peg$c34;
680 762
                 peg$currPos += 2;
681 763
               } else {
682 764
                 s0 = peg$FAILED;
683
-                if (peg$silentFails === 0) { peg$fail(peg$c31); }
765
+                if (peg$silentFails === 0) { peg$fail(peg$c35); }
684 766
               }
685 767
             }
686 768
           }
... ...
@@ -690,55 +772,6 @@ p2c2 = (function() {
690 772
       return s0;
691 773
     }
692 774
 
693
-    function peg$parseclosetag() {
694
-      var s0, s1, s2, s3, s4;
695
-
696
-      s0 = peg$currPos;
697
-      s1 = peg$currPos;
698
-      if (input.substr(peg$currPos, 2) === peg$c32) {
699
-        s2 = peg$c32;
700
-        peg$currPos += 2;
701
-      } else {
702
-        s2 = peg$FAILED;
703
-        if (peg$silentFails === 0) { peg$fail(peg$c33); }
704
-      }
705
-      if (s2 !== peg$FAILED) {
706
-        s3 = peg$parsevalidFormatTag();
707
-        if (s3 !== peg$FAILED) {
708
-          if (input.charCodeAt(peg$currPos) === 62) {
709
-            s4 = peg$c17;
710
-            peg$currPos++;
711
-          } else {
712
-            s4 = peg$FAILED;
713
-            if (peg$silentFails === 0) { peg$fail(peg$c18); }
714
-          }
715
-          if (s4 !== peg$FAILED) {
716
-            s2 = [s2, s3, s4];
717
-            s1 = s2;
718
-          } else {
719
-            peg$currPos = s1;
720
-            s1 = peg$FAILED;
721
-          }
722
-        } else {
723
-          peg$currPos = s1;
724
-          s1 = peg$FAILED;
725
-        }
726
-      } else {
727
-        peg$currPos = s1;
728
-        s1 = peg$FAILED;
729
-      }
730
-      if (s1 !== peg$FAILED) {
731
-        s0 = input.substring(s0, peg$currPos);
732
-      } else {
733
-        s0 = s1;
734
-      }
735
-      if (s0 === peg$FAILED) {
736
-        s0 = peg$parseinvalidCloseTag();
737
-      }
738
-
739
-      return s0;
740
-    }
741
-
742 775
     function peg$parseinvalidOpenTag() {
743 776
       var s0, s1, s2, s3;
744 777
 
... ...
@@ -762,7 +795,7 @@ p2c2 = (function() {
762 795
           }
763 796
           if (s3 !== peg$FAILED) {
764 797
             peg$savedPos = s0;
765
-            s1 = peg$c34();
798
+            s1 = peg$c36();
766 799
             s0 = s1;
767 800
           } else {
768 801
             peg$currPos = s0;
... ...
@@ -784,12 +817,12 @@ p2c2 = (function() {
784 817
       var s0, s1, s2, s3;
785 818
 
786 819
       s0 = peg$currPos;
787
-      if (input.substr(peg$currPos, 2) === peg$c32) {
788
-        s1 = peg$c32;
820
+      if (input.substr(peg$currPos, 2) === peg$c25) {
821
+        s1 = peg$c25;
789 822
         peg$currPos += 2;
790 823
       } else {
791 824
         s1 = peg$FAILED;
792
-        if (peg$silentFails === 0) { peg$fail(peg$c33); }
825
+        if (peg$silentFails === 0) { peg$fail(peg$c26); }
793 826
       }
794 827
       if (s1 !== peg$FAILED) {
795 828
         s2 = peg$parseinvalidTag();
... ...
@@ -803,7 +836,7 @@ p2c2 = (function() {
803 836
           }
804 837
           if (s3 !== peg$FAILED) {
805 838
             peg$savedPos = s0;
806
-            s1 = peg$c34();
839
+            s1 = peg$c36();
807 840
             s0 = s1;
808 841
           } else {
809 842
             peg$currPos = s0;
... ...
@@ -825,30 +858,30 @@ p2c2 = (function() {
825 858
       var s0, s1, s2, s3;
826 859
 
827 860
       s0 = peg$currPos;
828
-      if (peg$c35.test(input.charAt(peg$currPos))) {
861
+      if (peg$c37.test(input.charAt(peg$currPos))) {
829 862
         s1 = input.charAt(peg$currPos);
830 863
         peg$currPos++;
831 864
       } else {
832 865
         s1 = peg$FAILED;
833
-        if (peg$silentFails === 0) { peg$fail(peg$c36); }
866
+        if (peg$silentFails === 0) { peg$fail(peg$c38); }
834 867
       }
835 868
       if (s1 !== peg$FAILED) {
836 869
         s2 = [];
837
-        if (peg$c37.test(input.charAt(peg$currPos))) {
870
+        if (peg$c39.test(input.charAt(peg$currPos))) {
838 871
           s3 = input.charAt(peg$currPos);
839 872
           peg$currPos++;
840 873
         } else {
841 874
           s3 = peg$FAILED;
842
-          if (peg$silentFails === 0) { peg$fail(peg$c38); }
875
+          if (peg$silentFails === 0) { peg$fail(peg$c40); }
843 876
         }
844 877
         while (s3 !== peg$FAILED) {
845 878
           s2.push(s3);
846
-          if (peg$c37.test(input.charAt(peg$currPos))) {
879
+          if (peg$c39.test(input.charAt(peg$currPos))) {
847 880
             s3 = input.charAt(peg$currPos);
848 881
             peg$currPos++;
849 882
           } else {
850 883
             s3 = peg$FAILED;
851
-            if (peg$silentFails === 0) { peg$fail(peg$c38); }
884
+            if (peg$silentFails === 0) { peg$fail(peg$c40); }
852 885
           }
853 886
         }
854 887
         if (s2 !== peg$FAILED) {
... ...
@@ -870,12 +903,12 @@ p2c2 = (function() {
870 903
       var s0, s1, s2, s3, s4, s5;
871 904
 
872 905
       s0 = peg$currPos;
873
-      if (input.substr(peg$currPos, 2) === peg$c39) {
874
-        s1 = peg$c39;
906
+      if (input.substr(peg$currPos, 2) === peg$c41) {
907
+        s1 = peg$c41;
875 908
         peg$currPos += 2;
876 909
       } else {
877 910
         s1 = peg$FAILED;
878
-        if (peg$silentFails === 0) { peg$fail(peg$c40); }
911
+        if (peg$silentFails === 0) { peg$fail(peg$c42); }
879 912
       }
880 913
       if (s1 !== peg$FAILED) {
881 914
         s2 = peg$parsetagAttributes();
... ...
@@ -889,34 +922,34 @@ p2c2 = (function() {
889 922
           }
890 923
           if (s3 !== peg$FAILED) {
891 924
             s4 = [];
892
-            if (peg$c41.test(input.charAt(peg$currPos))) {
925
+            if (peg$c43.test(input.charAt(peg$currPos))) {
893 926
               s5 = input.charAt(peg$currPos);
894 927
               peg$currPos++;
895 928
             } else {
896 929
               s5 = peg$FAILED;
897
-              if (peg$silentFails === 0) { peg$fail(peg$c42); }
930
+              if (peg$silentFails === 0) { peg$fail(peg$c44); }
898 931
             }
899 932
             while (s5 !== peg$FAILED) {
900 933
               s4.push(s5);
901
-              if (peg$c41.test(input.charAt(peg$currPos))) {
934
+              if (peg$c43.test(input.charAt(peg$currPos))) {
902 935
                 s5 = input.charAt(peg$currPos);
903 936
                 peg$currPos++;
904 937
               } else {
905 938
                 s5 = peg$FAILED;
906
-                if (peg$silentFails === 0) { peg$fail(peg$c42); }
939
+                if (peg$silentFails === 0) { peg$fail(peg$c44); }
907 940
               }
908 941
             }
909 942
             if (s4 !== peg$FAILED) {
910
-              if (input.substr(peg$currPos, 4) === peg$c43) {
911
-                s5 = peg$c43;
943
+              if (input.substr(peg$currPos, 4) === peg$c45) {
944
+                s5 = peg$c45;
912 945
                 peg$currPos += 4;
913 946
               } else {
914 947
                 s5 = peg$FAILED;
915
-                if (peg$silentFails === 0) { peg$fail(peg$c44); }
948
+                if (peg$silentFails === 0) { peg$fail(peg$c46); }
916 949
               }
917 950
               if (s5 !== peg$FAILED) {
918 951
                 peg$savedPos = s0;
919
-                s1 = peg$c45(s2);
952
+                s1 = peg$c47(s2);
920 953
                 s0 = s1;
921 954
               } else {
922 955
                 peg$currPos = s0;
... ...
@@ -949,17 +982,17 @@ p2c2 = (function() {
949 982
       s1 = [];
950 983
       s2 = peg$currPos;
951 984
       if (input.charCodeAt(peg$currPos) === 32) {
952
-        s3 = peg$c46;
985
+        s3 = peg$c48;
953 986
         peg$currPos++;
954 987
       } else {
955 988
         s3 = peg$FAILED;
956
-        if (peg$silentFails === 0) { peg$fail(peg$c47); }
989
+        if (peg$silentFails === 0) { peg$fail(peg$c49); }
957 990
       }
958 991
       if (s3 !== peg$FAILED) {
959 992
         s4 = peg$parsetagAttribute();
960 993
         if (s4 !== peg$FAILED) {
961 994
           peg$savedPos = s2;
962
-          s3 = peg$c48(s3, s4);
995
+          s3 = peg$c50(s3, s4);
963 996
           s2 = s3;
964 997
         } else {
965 998
           peg$currPos = s2;
... ...
@@ -973,17 +1006,17 @@ p2c2 = (function() {
973 1006
         s1.push(s2);
974 1007
         s2 = peg$currPos;
975 1008
         if (input.charCodeAt(peg$currPos) === 32) {
976
-          s3 = peg$c46;
1009
+          s3 = peg$c48;
977 1010
           peg$currPos++;
978 1011
         } else {
979 1012
           s3 = peg$FAILED;
980
-          if (peg$silentFails === 0) { peg$fail(peg$c47); }
1013
+          if (peg$silentFails === 0) { peg$fail(peg$c49); }
981 1014
         }
982 1015
         if (s3 !== peg$FAILED) {
983 1016
           s4 = peg$parsetagAttribute();
984 1017
           if (s4 !== peg$FAILED) {
985 1018
             peg$savedPos = s2;
986
-            s3 = peg$c48(s3, s4);
1019
+            s3 = peg$c50(s3, s4);
987 1020
             s2 = s3;
988 1021
           } else {
989 1022
             peg$currPos = s2;
... ...
@@ -996,7 +1029,7 @@ p2c2 = (function() {
996 1029
       }
997 1030
       if (s1 !== peg$FAILED) {
998 1031
         peg$savedPos = s0;
999
-        s1 = peg$c49(s1);
1032
+        s1 = peg$c51(s1);
1000 1033
       }
1001 1034
       s0 = s1;
1002 1035
 
... ...
@@ -1009,22 +1042,22 @@ p2c2 = (function() {
1009 1042
       s0 = peg$currPos;
1010 1043
       s1 = peg$currPos;
1011 1044
       s2 = [];
1012
-      if (peg$c50.test(input.charAt(peg$currPos))) {
1045
+      if (peg$c52.test(input.charAt(peg$currPos))) {
1013 1046
         s3 = input.charAt(peg$currPos);
1014 1047
         peg$currPos++;
1015 1048
       } else {
1016 1049
         s3 = peg$FAILED;
1017
-        if (peg$silentFails === 0) { peg$fail(peg$c51); }
1050
+        if (peg$silentFails === 0) { peg$fail(peg$c53); }
1018 1051
       }
1019 1052
       if (s3 !== peg$FAILED) {
1020 1053
         while (s3 !== peg$FAILED) {
1021 1054
           s2.push(s3);
1022
-          if (peg$c50.test(input.charAt(peg$currPos))) {
1055
+          if (peg$c52.test(input.charAt(peg$currPos))) {
1023 1056
             s3 = input.charAt(peg$currPos);
1024 1057
             peg$currPos++;
1025 1058
           } else {
1026 1059
             s3 = peg$FAILED;
1027
-            if (peg$silentFails === 0) { peg$fail(peg$c51); }
1060
+            if (peg$silentFails === 0) { peg$fail(peg$c53); }
1028 1061
           }
1029 1062
         }
1030 1063
       } else {
... ...
@@ -1037,31 +1070,31 @@ p2c2 = (function() {
1037 1070
       }
1038 1071
       if (s1 !== peg$FAILED) {
1039 1072
         s2 = peg$currPos;
1040
-        if (input.substr(peg$currPos, 2) === peg$c52) {
1041
-          s3 = peg$c52;
1073
+        if (input.substr(peg$currPos, 2) === peg$c54) {
1074
+          s3 = peg$c54;
1042 1075
           peg$currPos += 2;
1043 1076
         } else {
1044 1077
           s3 = peg$FAILED;
1045
-          if (peg$silentFails === 0) { peg$fail(peg$c53); }
1078
+          if (peg$silentFails === 0) { peg$fail(peg$c55); }
1046 1079
         }
1047 1080
         if (s3 !== peg$FAILED) {
1048 1081
           s4 = peg$currPos;
1049 1082
           s5 = [];
1050
-          if (peg$c54.test(input.charAt(peg$currPos))) {
1083
+          if (peg$c56.test(input.charAt(peg$currPos))) {
1051 1084
             s6 = input.charAt(peg$currPos);
1052 1085
             peg$currPos++;
1053 1086
           } else {
1054 1087
             s6 = peg$FAILED;
1055
-            if (peg$silentFails === 0) { peg$fail(peg$c55); }
1088
+            if (peg$silentFails === 0) { peg$fail(peg$c57); }
1056 1089
           }
1057 1090
           while (s6 !== peg$FAILED) {
1058 1091
             s5.push(s6);
1059
-            if (peg$c54.test(input.charAt(peg$currPos))) {
1092
+            if (peg$c56.test(input.charAt(peg$currPos))) {
1060 1093
               s6 = input.charAt(peg$currPos);
1061 1094
               peg$currPos++;
1062 1095
             } else {
1063 1096
               s6 = peg$FAILED;
1064
-              if (peg$silentFails === 0) { peg$fail(peg$c55); }
1097
+              if (peg$silentFails === 0) { peg$fail(peg$c57); }
1065 1098
             }
1066 1099
           }
1067 1100
           if (s5 !== peg$FAILED) {
... ...
@@ -1071,15 +1104,15 @@ p2c2 = (function() {
1071 1104
           }
1072 1105
           if (s4 !== peg$FAILED) {
1073 1106
             if (input.charCodeAt(peg$currPos) === 34) {
1074
-              s5 = peg$c56;
1107
+              s5 = peg$c58;
1075 1108
               peg$currPos++;
1076 1109
             } else {
1077 1110
               s5 = peg$FAILED;
1078
-              if (peg$silentFails === 0) { peg$fail(peg$c57); }
1111
+              if (peg$silentFails === 0) { peg$fail(peg$c59); }
1079 1112
             }
1080 1113
             if (s5 !== peg$FAILED) {
1081 1114
               peg$savedPos = s2;
1082
-              s3 = peg$c58(s1, s4);
1115
+              s3 = peg$c60(s1, s4);
1083 1116
               s2 = s3;
1084 1117
             } else {
1085 1118
               peg$currPos = s2;
... ...
@@ -1098,7 +1131,7 @@ p2c2 = (function() {
1098 1131
         }
1099 1132
         if (s2 !== peg$FAILED) {
1100 1133
           peg$savedPos = s0;
1101
-          s1 = peg$c59(s1, s2);
1134
+          s1 = peg$c61(s1, s2);
1102 1135
           s0 = s1;
1103 1136
         } else {
1104 1137
           peg$currPos = s0;
... ...
@@ -1139,7 +1172,7 @@ p2c2 = (function() {
1139 1172
       }
1140 1173
       if (s1 !== peg$FAILED) {
1141 1174
         peg$savedPos = s0;
1142
-        s1 = peg$c60(s1);
1175
+        s1 = peg$c62(s1);
1143 1176
       }
1144 1177
       s0 = s1;
1145 1178
 
... ...
@@ -1153,17 +1186,17 @@ p2c2 = (function() {
1153 1186
       s1 = peg$parsenorlogeYear();
1154 1187
       if (s1 !== peg$FAILED) {
1155 1188
         if (input.charCodeAt(peg$currPos) === 47) {
1156
-          s2 = peg$c61;
1189
+          s2 = peg$c63;
1157 1190
           peg$currPos++;
1158 1191
         } else {
1159 1192
           s2 = peg$FAILED;
1160
-          if (peg$silentFails === 0) { peg$fail(peg$c62); }
1193
+          if (peg$silentFails === 0) { peg$fail(peg$c64); }
1161 1194
         }
1162 1195
         if (s2 !== peg$FAILED) {
1163 1196
           s3 = peg$parselongNorloge();
1164 1197
           if (s3 !== peg$FAILED) {
1165 1198
             peg$savedPos = s0;
1166
-            s1 = peg$c63(s1, s3);
1199
+            s1 = peg$c65(s1, s3);
1167 1200
             s0 = s1;
1168 1201
           } else {
1169 1202
             peg$currPos = s0;
... ...
@@ -1186,22 +1219,22 @@ p2c2 = (function() {
1186 1219
 
1187 1220
       s0 = peg$currPos;
1188 1221
       s1 = [];
1189
-      if (peg$c64.test(input.charAt(peg$currPos))) {
1222
+      if (peg$c66.test(input.charAt(peg$currPos))) {
1190 1223
         s2 = input.charAt(peg$currPos);
1191 1224
         peg$currPos++;
1192 1225
       } else {
1193 1226
         s2 = peg$FAILED;
1194
-        if (peg$silentFails === 0) { peg$fail(peg$c65); }
1227
+        if (peg$silentFails === 0) { peg$fail(peg$c67); }
1195 1228
       }
1196 1229
       if (s2 !== peg$FAILED) {
1197 1230
         while (s2 !== peg$FAILED) {
1198 1231
           s1.push(s2);
1199
-          if (peg$c64.test(input.charAt(peg$currPos))) {
1232
+          if (peg$c66.test(input.charAt(peg$currPos))) {
1200 1233
             s2 = input.charAt(peg$currPos);
1201 1234
             peg$currPos++;
1202 1235
           } else {
1203 1236
             s2 = peg$FAILED;
1204
-            if (peg$silentFails === 0) { peg$fail(peg$c65); }
1237
+            if (peg$silentFails === 0) { peg$fail(peg$c67); }
1205 1238
           }
1206 1239
         }
1207 1240
       } else {
... ...
@@ -1209,7 +1242,7 @@ p2c2 = (function() {
1209 1242
       }
1210 1243
       if (s1 !== peg$FAILED) {
1211 1244
         peg$savedPos = s0;
1212
-        s1 = peg$c66(s1);
1245
+        s1 = peg$c68(s1);
1213 1246
       }
1214 1247
       s0 = s1;
1215 1248
 
... ...
@@ -1223,27 +1256,27 @@ p2c2 = (function() {
1223 1256
       s1 = peg$parsenorlogeMonth();
1224 1257
       if (s1 !== peg$FAILED) {
1225 1258
         if (input.charCodeAt(peg$currPos) === 47) {
1226
-          s2 = peg$c61;
1259
+          s2 = peg$c63;
1227 1260
           peg$currPos++;
1228 1261
         } else {
1229 1262
           s2 = peg$FAILED;
1230
-          if (peg$silentFails === 0) { peg$fail(peg$c62); }
1263
+          if (peg$silentFails === 0) { peg$fail(peg$c64); }
1231 1264
         }
1232 1265
         if (s2 !== peg$FAILED) {
1233 1266
           s3 = peg$parsenorlogeDay();
1234 1267
           if (s3 !== peg$FAILED) {
1235 1268
             if (input.charCodeAt(peg$currPos) === 35) {
1236
-              s4 = peg$c67;
1269
+              s4 = peg$c69;
1237 1270
               peg$currPos++;
1238 1271
             } else {
1239 1272
               s4 = peg$FAILED;
1240
-              if (peg$silentFails === 0) { peg$fail(peg$c68); }
1273
+              if (peg$silentFails === 0) { peg$fail(peg$c70); }
1241 1274
             }
1242 1275
             if (s4 !== peg$FAILED) {
1243 1276
               s5 = peg$parsenormalNorloge();
1244 1277
               if (s5 !== peg$FAILED) {
1245 1278
                 peg$savedPos = s0;
1246
-                s1 = peg$c69(s1, s3, s5);
1279
+                s1 = peg$c71(s1, s3, s5);
1247 1280
                 s0 = s1;
1248 1281
               } else {
1249 1282
                 peg$currPos = s0;
... ...
@@ -1273,24 +1306,24 @@ p2c2 = (function() {
1273 1306
       var s0, s1, s2;
1274 1307
 
1275 1308
       s0 = peg$currPos;
1276
-      if (peg$c70.test(input.charAt(peg$currPos))) {
1309
+      if (peg$c72.test(input.charAt(peg$currPos))) {
1277 1310
         s1 = input.charAt(peg$currPos);
1278 1311
         peg$currPos++;
1279 1312
       } else {
1280 1313
         s1 = peg$FAILED;
1281
-        if (peg$silentFails === 0) { peg$fail(peg$c71); }
1314
+        if (peg$silentFails === 0) { peg$fail(peg$c73); }
1282 1315
       }
1283 1316
       if (s1 !== peg$FAILED) {
1284
-        if (peg$c64.test(input.charAt(peg$currPos))) {
1317
+        if (peg$c66.test(input.charAt(peg$currPos))) {
1285 1318
           s2 = input.charAt(peg$currPos);
1286 1319
           peg$currPos++;
1287 1320
         } else {
1288 1321
           s2 = peg$FAILED;
1289
-          if (peg$silentFails === 0) { peg$fail(peg$c65); }
1322
+          if (peg$silentFails === 0) { peg$fail(peg$c67); }
1290 1323
         }
1291 1324
         if (s2 !== peg$FAILED) {
1292 1325
           peg$savedPos = s0;
1293
-          s1 = peg$c72(s1, s2);
1326
+          s1 = peg$c74(s1, s2);
1294 1327
           s0 = s1;
1295 1328
         } else {
1296 1329
           peg$currPos = s0;
... ...
@@ -1308,24 +1341,24 @@ p2c2 = (function() {
1308 1341
       var s0, s1, s2;
1309 1342
 
1310 1343
       s0 = peg$currPos;
1311
-      if (peg$c73.test(input.charAt(peg$currPos))) {
1344
+      if (peg$c75.test(input.charAt(peg$currPos))) {
1312 1345
         s1 = input.charAt(peg$currPos);
1313 1346
         peg$currPos++;
1314 1347
       } else {
1315 1348
         s1 = peg$FAILED;
1316
-        if (peg$silentFails === 0) { peg$fail(peg$c74); }
1349
+        if (peg$silentFails === 0) { peg$fail(peg$c76); }
1317 1350
       }
1318 1351
       if (s1 !== peg$FAILED) {
1319
-        if (peg$c64.test(input.charAt(peg$currPos))) {
1352
+        if (peg$c66.test(input.charAt(peg$currPos))) {
1320 1353
           s2 = input.charAt(peg$currPos);
1321 1354
           peg$currPos++;
1322 1355
         } else {
1323 1356
           s2 = peg$FAILED;
1324
-          if (peg$silentFails === 0) { peg$fail(peg$c65); }
1357
+          if (peg$silentFails === 0) { peg$fail(peg$c67); }
1325 1358
         }
1326 1359
         if (s2 !== peg$FAILED) {
1327 1360
           peg$savedPos = s0;
1328
-          s1 = peg$c72(s1, s2);
1361
+          s1 = peg$c74(s1, s2);
1329 1362
           s0 = s1;
1330 1363
         } else {
1331 1364
           peg$currPos = s0;
... ...
@@ -1346,17 +1379,17 @@ p2c2 = (function() {
1346 1379
       s1 = peg$parseshortNorloge();
1347 1380
       if (s1 !== peg$FAILED) {
1348 1381
         if (input.charCodeAt(peg$currPos) === 58) {
1349
-          s2 = peg$c75;
1382
+          s2 = peg$c77;
1350 1383
           peg$currPos++;
1351 1384
         } else {
1352 1385
           s2 = peg$FAILED;
1353
-          if (peg$silentFails === 0) { peg$fail(peg$c76); }
1386
+          if (peg$silentFails === 0) { peg$fail(peg$c78); }
1354 1387
         }
1355 1388
         if (s2 !== peg$FAILED) {
1356 1389
           s3 = peg$parsenorlogeSeconds();
1357 1390
           if (s3 !== peg$FAILED) {
1358 1391
             peg$savedPos = s0;
1359
-            s1 = peg$c77(s1, s3);
1392
+            s1 = peg$c79(s1, s3);
1360 1393
             s0 = s1;
1361 1394
           } else {
1362 1395
             peg$currPos = s0;
... ...
@@ -1381,17 +1414,17 @@ p2c2 = (function() {
1381 1414
       s1 = peg$parsenorlogeHours();
1382 1415
       if (s1 !== peg$FAILED) {
1383 1416
         if (input.charCodeAt(peg$currPos) === 58) {
1384
-          s2 = peg$c75;
1417
+          s2 = peg$c77;
1385 1418
           peg$currPos++;
1386 1419
         } else {
1387 1420
           s2 = peg$FAILED;
1388
-          if (peg$silentFails === 0) { peg$fail(peg$c76); }
1421
+          if (peg$silentFails === 0) { peg$fail(peg$c78); }
1389 1422
         }
1390 1423
         if (s2 !== peg$FAILED) {
1391 1424
           s3 = peg$parsenorlogeMinutes();
1392 1425
           if (s3 !== peg$FAILED) {
1393 1426
             peg$savedPos = s0;
1394
-            s1 = peg$c78(s1, s3);
1427
+            s1 = peg$c80(s1, s3);
1395 1428
             s0 = s1;
1396 1429
           } else {
1397 1430
             peg$currPos = s0;
... ...
@@ -1413,24 +1446,24 @@ p2c2 = (function() {
1413 1446
       var s0, s1, s2;
1414 1447
 
1415 1448
       s0 = peg$currPos;
1416
-      if (peg$c79.test(input.charAt(peg$currPos))) {
1449
+      if (peg$c81.test(input.charAt(peg$currPos))) {
1417 1450
         s1 = input.charAt(peg$currPos);
1418 1451
         peg$currPos++;
1419 1452
       } else {
1420 1453
         s1 = peg$FAILED;
1421
-        if (peg$silentFails === 0) { peg$fail(peg$c80); }
1454
+        if (peg$silentFails === 0) { peg$fail(peg$c82); }
1422 1455
       }
1423 1456
       if (s1 !== peg$FAILED) {
1424
-        if (peg$c73.test(input.charAt(peg$currPos))) {
1457
+        if (peg$c75.test(input.charAt(peg$currPos))) {
1425 1458
           s2 = input.charAt(peg$currPos);
1426 1459
           peg$currPos++;
1427 1460
         } else {
1428 1461
           s2 = peg$FAILED;
1429
-          if (peg$silentFails === 0) { peg$fail(peg$c74); }
1462
+          if (peg$silentFails === 0) { peg$fail(peg$c76); }
1430 1463
         }
1431 1464
         if (s2 !== peg$FAILED) {
1432 1465
           peg$savedPos = s0;
1433
-          s1 = peg$c72(s1, s2);
1466
+          s1 = peg$c74(s1, s2);
1434 1467
           s0 = s1;
1435 1468
         } else {
1436 1469
           peg$currPos = s0;
... ...
@@ -1448,24 +1481,24 @@ p2c2 = (function() {
1448 1481
       var s0, s1, s2;
1449 1482
 
1450 1483
       s0 = peg$currPos;
1451
-      if (peg$c81.test(input.charAt(peg$currPos))) {
1484
+      if (peg$c83.test(input.charAt(peg$currPos))) {
1452 1485
         s1 = input.charAt(peg$currPos);
1453 1486
         peg$currPos++;
1454 1487
       } else {
1455 1488
         s1 = peg$FAILED;
1456
-        if (peg$silentFails === 0) { peg$fail(peg$c82); }
1489
+        if (peg$silentFails === 0) { peg$fail(peg$c84); }
1457 1490
       }
1458 1491
       if (s1 !== peg$FAILED) {
1459
-        if (peg$c64.test(input.charAt(peg$currPos))) {
1492
+        if (peg$c66.test(input.charAt(peg$currPos))) {
1460 1493
           s2 = input.charAt(peg$currPos);
1461 1494
           peg$currPos++;
1462 1495
         } else {
1463 1496
           s2 = peg$FAILED;
1464
-          if (peg$silentFails === 0) { peg$fail(peg$c65); }
1497
+          if (peg$silentFails === 0) { peg$fail(peg$c67); }
1465 1498
         }
1466 1499
         if (s2 !== peg$FAILED) {
1467 1500
           peg$savedPos = s0;
1468
-          s1 = peg$c72(s1, s2);
1501
+          s1 = peg$c74(s1, s2);
1469 1502
           s0 = s1;
1470 1503
         } else {
1471 1504
           peg$currPos = s0;
... ...
@@ -1483,24 +1516,24 @@ p2c2 = (function() {
1483 1516
       var s0, s1, s2;
1484 1517
 
1485 1518
       s0 = peg$currPos;
1486
-      if (peg$c81.test(input.charAt(peg$currPos))) {
1519
+      if (peg$c83.test(input.charAt(peg$currPos))) {
1487 1520
         s1 = input.charAt(peg$currPos);
1488 1521
         peg$currPos++;
1489 1522
       } else {
1490 1523
         s1 = peg$FAILED;
1491
-        if (peg$silentFails === 0) { peg$fail(peg$c82); }
1524
+        if (peg$silentFails === 0) { peg$fail(peg$c84); }
1492 1525
       }
1493 1526
       if (s1 !== peg$FAILED) {
1494
-        if (peg$c64.test(input.charAt(peg$currPos))) {
1527
+        if (peg$c66.test(input.charAt(peg$currPos))) {
1495 1528
           s2 = input.charAt(peg$currPos);
1496 1529
           peg$currPos++;
1497 1530
         } else {
1498 1531
           s2 = peg$FAILED;
1499
-          if (peg$silentFails === 0) { peg$fail(peg$c65); }
1532
+          if (peg$silentFails === 0) { peg$fail(peg$c67); }
1500 1533
         }
1501 1534
         if (s2 !== peg$FAILED) {
1502 1535
           peg$savedPos = s0;
1503
-          s1 = peg$c72(s1, s2);
1536
+          s1 = peg$c74(s1, s2);
1504 1537
           s0 = s1;
1505 1538
         } else {
1506 1539
           peg$currPos = s0;
... ...
@@ -1519,30 +1552,30 @@ p2c2 = (function() {
1519 1552
 
1520 1553
       s0 = peg$currPos;
1521 1554
       if (input.charCodeAt(peg$currPos) === 35) {
1522
-        s1 = peg$c67;
1555
+        s1 = peg$c69;
1523 1556
         peg$currPos++;
1524 1557
       } else {
1525 1558
         s1 = peg$FAILED;
1526
-        if (peg$silentFails === 0) { peg$fail(peg$c68); }
1559
+        if (peg$silentFails === 0) { peg$fail(peg$c70); }
1527 1560
       }
1528 1561
       if (s1 !== peg$FAILED) {
1529 1562
         s2 = [];
1530
-        if (peg$c83.test(input.charAt(peg$currPos))) {
1563
+        if (peg$c85.test(input.charAt(peg$currPos))) {
1531 1564
           s3 = input.charAt(peg$currPos);
1532 1565
           peg$currPos++;
1533 1566
         } else {
1534 1567
           s3 = peg$FAILED;
1535
-          if (peg$silentFails === 0) { peg$fail(peg$c84); }
1568
+          if (peg$silentFails === 0) { peg$fail(peg$c86); }
1536 1569
         }
1537 1570
         if (s3 !== peg$FAILED) {
1538 1571
           while (s3 !== peg$FAILED) {
1539 1572
             s2.push(s3);
1540
-            if (peg$c83.test(input.charAt(peg$currPos))) {
1573
+            if (peg$c85.test(input.charAt(peg$currPos))) {
1541 1574
               s3 = input.charAt(peg$currPos);
1542 1575
               peg$currPos++;
1543 1576
             } else {
1544 1577
               s3 = peg$FAILED;
1545
-              if (peg$silentFails === 0) { peg$fail(peg$c84); }
1578
+              if (peg$silentFails === 0) { peg$fail(peg$c86); }
1546 1579
             }
1547 1580
           }
1548 1581
         } else {
... ...
@@ -1550,7 +1583,7 @@ p2c2 = (function() {
1550 1583
         }
1551 1584
         if (s2 !== peg$FAILED) {
1552 1585
           peg$savedPos = s0;
1553
-          s1 = peg$c85(s2);
1586
+          s1 = peg$c87(s2);
1554 1587
           s0 = s1;
1555 1588
         } else {
1556 1589
           peg$currPos = s0;
... ...
@@ -1569,22 +1602,22 @@ p2c2 = (function() {
1569 1602
 
1570 1603
       s0 = peg$currPos;
1571 1604
       s1 = [];
1572
-      if (peg$c86.test(input.charAt(peg$currPos))) {
1605
+      if (peg$c88.test(input.charAt(peg$currPos))) {
1573 1606
         s2 = input.charAt(peg$currPos);
1574 1607
         peg$currPos++;
1575 1608
       } else {
1576 1609
         s2 = peg$FAILED;
1577
-        if (peg$silentFails === 0) { peg$fail(peg$c87); }
1610
+        if (peg$silentFails === 0) { peg$fail(peg$c89); }
1578 1611
       }
1579 1612
       if (s2 !== peg$FAILED) {
1580 1613
         while (s2 !== peg$FAILED) {
1581 1614
           s1.push(s2);
1582
-          if (peg$c86.test(input.charAt(peg$currPos))) {
1615
+          if (peg$c88.test(input.charAt(peg$currPos))) {
1583 1616
             s2 = input.charAt(peg$currPos);
1584 1617
             peg$currPos++;
1585 1618
           } else {
1586 1619
             s2 = peg$FAILED;
1587
-            if (peg$silentFails === 0) { peg$fail(peg$c87); }
1620
+            if (peg$silentFails === 0) { peg$fail(peg$c89); }
1588 1621
           }
1589 1622
         }
1590 1623
       } else {
... ...
@@ -1603,12 +1636,12 @@ p2c2 = (function() {
1603 1636
           peg$silentFails++;
1604 1637
           s4 = peg$parsewhitespaces();
1605 1638
           if (s4 === peg$FAILED) {
1606
-            if (peg$c88.test(input.charAt(peg$currPos))) {
1639
+            if (peg$c90.test(input.charAt(peg$currPos))) {
1607 1640
               s4 = input.charAt(peg$currPos);
1608 1641
               peg$currPos++;
1609 1642
             } else {
1610 1643
               s4 = peg$FAILED;
1611
-              if (peg$silentFails === 0) { peg$fail(peg$c89); }
1644
+              if (peg$silentFails === 0) { peg$fail(peg$c91); }
1612 1645
             }
1613 1646
           }
1614 1647
           peg$silentFails--;
... ...
@@ -1620,7 +1653,7 @@ p2c2 = (function() {
1620 1653
           }
1621 1654
           if (s3 !== peg$FAILED) {
1622 1655
             peg$savedPos = s0;
1623
-            s1 = peg$c90(s1);
1656
+            s1 = peg$c92(s1);
1624 1657
             s0 = s1;
1625 1658
           } else {
1626 1659
             peg$currPos = s0;
... ...
@@ -1642,31 +1675,31 @@ p2c2 = (function() {
1642 1675
       var s0, s1, s2, s3;
1643 1676
 
1644 1677
       s0 = peg$currPos;
1645
-      if (input.substr(peg$currPos, 2) === peg$c91) {
1646
-        s1 = peg$c91;
1678
+      if (input.substr(peg$currPos, 2) === peg$c93) {
1679
+        s1 = peg$c93;
1647 1680
         peg$currPos += 2;
1648 1681
       } else {
1649 1682
         s1 = peg$FAILED;
1650
-        if (peg$silentFails === 0) { peg$fail(peg$c92); }
1683
+        if (peg$silentFails === 0) { peg$fail(peg$c94); }
1651 1684
       }
1652 1685
       if (s1 !== peg$FAILED) {
1653 1686
         s2 = [];
1654
-        if (peg$c93.test(input.charAt(peg$currPos))) {
1687
+        if (peg$c95.test(input.charAt(peg$currPos))) {
1655 1688
           s3 = input.charAt(peg$currPos);
1656 1689
           peg$currPos++;
1657 1690
         } else {
1658 1691
           s3 = peg$FAILED;
1659
-          if (peg$silentFails === 0) { peg$fail(peg$c94); }
1692
+          if (peg$silentFails === 0) { peg$fail(peg$c96); }
1660 1693
         }
1661 1694
         if (s3 !== peg$FAILED) {
1662 1695
           while (s3 !== peg$FAILED) {
1663 1696
             s2.push(s3);
1664
-            if (peg$c93.test(input.charAt(peg$currPos))) {
1697
+            if (peg$c95.test(input.charAt(peg$currPos))) {
1665 1698
               s3 = input.charAt(peg$currPos);
1666 1699
               peg$currPos++;
1667 1700
             } else {
1668 1701
               s3 = peg$FAILED;
1669
-              if (peg$silentFails === 0) { peg$fail(peg$c94); }
1702
+              if (peg$silentFails === 0) { peg$fail(peg$c96); }
1670 1703
             }
1671 1704
           }
1672 1705
         } else {
... ...
@@ -1674,15 +1707,15 @@ p2c2 = (function() {
1674 1707
         }
1675 1708
         if (s2 !== peg$FAILED) {
1676 1709
           if (input.charCodeAt(peg$currPos) === 93) {
1677
-            s3 = peg$c95;
1710
+            s3 = peg$c97;
1678 1711
             peg$currPos++;
1679 1712
           } else {
1680 1713
             s3 = peg$FAILED;
1681
-            if (peg$silentFails === 0) { peg$fail(peg$c96); }
1714
+            if (peg$silentFails === 0) { peg$fail(peg$c98); }
1682 1715
           }
1683 1716
           if (s3 !== peg$FAILED) {
1684 1717
             peg$savedPos = s0;
1685
-            s1 = peg$c97(s1, s2, s3);
1718
+            s1 = peg$c99(s1, s2, s3);
1686 1719
             s0 = s1;
1687 1720
           } else {
1688 1721
             peg$currPos = s0;
... ...
@@ -1703,12 +1736,12 @@ p2c2 = (function() {
1703 1736
     function peg$parsewhitespaces() {
1704 1737
       var s0, s1;
1705 1738
 
1706
-      if (peg$c98.test(input.charAt(peg$currPos))) {
1739
+      if (peg$c100.test(input.charAt(peg$currPos))) {
1707 1740
         s0 = input.charAt(peg$currPos);
1708 1741
         peg$currPos++;
1709 1742
       } else {
1710 1743
         s0 = peg$FAILED;
1711
-        if (peg$silentFails === 0) { peg$fail(peg$c99); }
1744
+        if (peg$silentFails === 0) { peg$fail(peg$c101); }
1712 1745
       }
1713 1746
       if (s0 === peg$FAILED) {
1714 1747
         s0 = peg$currPos;
... ...
@@ -1732,6 +1765,13 @@ p2c2 = (function() {
1732 1765
       return s0;
1733 1766
     }
1734 1767
 
1768
+
1769
+
1770
+    var p2c2 = {};
1771
+    p2c2.tagStack = [];
1772
+
1773
+
1774
+
1735 1775
     peg$result = peg$startRuleFunction();
1736 1776
 
1737 1777
     if (peg$result !== peg$FAILED && peg$currPos === input.length) {
... ...
@@ -1,6 +1,19 @@
1
+{
2
+
3
+var p2c2 = {};
4
+p2c2.tagStack = [];
5
+
6
+}
7
+
1 8
 post
2 9
  = items:postItem*
3
- { return items.join(""); }
10
+ {
11
+ 	var result = items.join("");
12
+    while(p2c2.tagStack.length > 0) {
13
+    	result += "</" + p2c2.tagStack.pop() + ">";
14
+    }
15
+    return result;
16
+ }
4 17
  
5 18
 postItem
6 19
  = url
... ...
@@ -25,16 +38,43 @@ teteCanard
25 38
  = [o0ô°øòó@]
26 39
 
27 40
 opentag
28
- = $("<" validFormatTag ">")
41
+ = validOpenTag
29 42
  / invalidOpenTag
30 43
 
31
-validFormatTag
32
- = ("b" / "i" / "s" / "u" / "tt")
44
+validOpenTag
45
+ = "<" tag:validFormatTag ">"
46
+ {
47
+ 	p2c2.tagStack.push(tag);
48
+    console.log("push " + tag);
49
+ 	return "<" + tag + ">";
50
+ }
33 51
  
34 52
 closetag
35
- = $("</" validFormatTag ">")
53
+ = validCloseTag
36 54
  / invalidCloseTag
37
- 
55
+
56
+validCloseTag
57
+ = "</" tag:validFormatTag ">"
58
+ {
59
+ 	var result = "";
60
+ 	for(;;) {
61
+      var poppedTag = p2c2.tagStack.pop();
62
+      if(poppedTag == undefined) {
63
+      	break;
64
+      }
65
+      if( poppedTag == tag) {
66
+      	result += "</" + tag + ">";
67
+        break;
68
+      } else {
69
+      	result += "</" + poppedTag + ">";
70
+      }
71
+    }
72
+    return result;
73
+ }
74
+
75
+validFormatTag
76
+ = ("b" / "i" / "s" / "u" / "tt")
77
+
38 78
 invalidOpenTag
39 79
  = "<" invalidTag ">"
40 80
  { return ""; }