Browse code

add issue #6 test

devnewton authored on 23/06/2016 16:32:10
Showing 3 changed files
... ...
@@ -13,7 +13,13 @@
13 13
         <input id="convert" type="button" value="Convert">
14 14
         <fieldset>
15 15
             <legend>Input : </legend>
16
-            <textarea id="input" rows="5" cols="80"></textarea>
16
+            <textarea id="input" rows="5" cols="80">
17
+>o_/ 22:23:56 #5766f86ae4b00e368dfab8a3 [:bondour]
18
+2016/06/19#10:22:01 les <b>moules<</b>
19
+\_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>
20
+<b><i>pas fermé</u>
21
+meuh> \_O< ahahah >_< ça fait 0 </single>
22
+            </textarea>
17 23
         </fieldset>
18 24
         <fieldset>
19 25
             <legend>Output : </legend>
... ...
@@ -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> <b><i>pas fermé</u>';
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);
... ...
@@ -64,8 +64,8 @@ p2c2 = (function() {
64 64
         peg$c19 = "_/",
65 65
         peg$c20 = { type: "literal", value: "_/", description: "\"_/\"" },
66 66
         peg$c21 = function() {return '<canard/>';},
67
-        peg$c22 = /^[o0\xF4\xB0\xF8\xF2\xF3@]/,
68
-        peg$c23 = { type: "class", value: "[o0\xF4\xB0\xF8\xF2\xF3@]", description: "[o0\xF4\xB0\xF8\xF2\xF3@]" },
67
+        peg$c22 = /^[oO0\xF4\xB0\xF8\xF2\xF3@]/,
68
+        peg$c23 = { type: "class", value: "[oO0\xF4\xB0\xF8\xF2\xF3@]", description: "[oO0\xF4\xB0\xF8\xF2\xF3@]" },
69 69
         peg$c24 = function(tag) {
70 70
          	p2c2.tagStack.push(tag);
71 71
             console.log("push " + tag);
... ...
@@ -175,6 +175,7 @@ p2c2 = (function() {
175 175
           return '<totoz>' + totozId + '</totoz>'; },
176 176
         peg$c100 = /^[ \t\r\n]/,
177 177
         peg$c101 = { type: "class", value: "[ \\t\\r\\n]", description: "[ \\t\\r\\n]" },
178
+        peg$c102 = function() { return location().start.offset == 0; },
178 179
 
179 180
         peg$currPos          = 0,
180 181
         peg$savedPos         = 0,
... ...
@@ -1598,63 +1599,69 @@ p2c2 = (function() {
1598 1599
     }
1599 1600
 
1600 1601
     function peg$parsebigorno() {
1601
-      var s0, s1, s2, s3, s4;
1602
+      var s0, s1, s2, s3, s4, s5;
1602 1603
 
1603 1604
       s0 = peg$currPos;
1604
-      s1 = [];
1605
-      if (peg$c88.test(input.charAt(peg$currPos))) {
1606
-        s2 = input.charAt(peg$currPos);
1607
-        peg$currPos++;
1608
-      } else {
1609
-        s2 = peg$FAILED;
1610
-        if (peg$silentFails === 0) { peg$fail(peg$c89); }
1611
-      }
1612
-      if (s2 !== peg$FAILED) {
1613
-        while (s2 !== peg$FAILED) {
1614
-          s1.push(s2);
1615
-          if (peg$c88.test(input.charAt(peg$currPos))) {
1616
-            s2 = input.charAt(peg$currPos);
1617
-            peg$currPos++;
1618
-          } else {
1619
-            s2 = peg$FAILED;
1620
-            if (peg$silentFails === 0) { peg$fail(peg$c89); }
1621
-          }
1622
-        }
1623
-      } else {
1624
-        s1 = peg$FAILED;
1625
-      }
1605
+      s1 = peg$parsewhitespaces();
1626 1606
       if (s1 !== peg$FAILED) {
1627
-        if (input.charCodeAt(peg$currPos) === 60) {
1628
-          s2 = peg$c15;
1607
+        s2 = [];
1608
+        if (peg$c88.test(input.charAt(peg$currPos))) {
1609
+          s3 = input.charAt(peg$currPos);
1629 1610
           peg$currPos++;
1630 1611
         } else {
1631
-          s2 = peg$FAILED;
1632
-          if (peg$silentFails === 0) { peg$fail(peg$c16); }
1612
+          s3 = peg$FAILED;
1613
+          if (peg$silentFails === 0) { peg$fail(peg$c89); }
1633 1614
         }
1634
-        if (s2 !== peg$FAILED) {
1635
-          s3 = peg$currPos;
1636
-          peg$silentFails++;
1637
-          s4 = peg$parsewhitespaces();
1638
-          if (s4 === peg$FAILED) {
1639
-            if (peg$c90.test(input.charAt(peg$currPos))) {
1640
-              s4 = input.charAt(peg$currPos);
1615
+        if (s3 !== peg$FAILED) {
1616
+          while (s3 !== peg$FAILED) {
1617
+            s2.push(s3);
1618
+            if (peg$c88.test(input.charAt(peg$currPos))) {
1619
+              s3 = input.charAt(peg$currPos);
1641 1620
               peg$currPos++;
1642 1621
             } else {
1643
-              s4 = peg$FAILED;
1644
-              if (peg$silentFails === 0) { peg$fail(peg$c91); }
1622
+              s3 = peg$FAILED;
1623
+              if (peg$silentFails === 0) { peg$fail(peg$c89); }
1645 1624
             }
1646 1625
           }
1647
-          peg$silentFails--;
1648
-          if (s4 !== peg$FAILED) {
1649
-            peg$currPos = s3;
1650
-            s3 = void 0;
1626
+        } else {
1627
+          s2 = peg$FAILED;
1628
+        }
1629
+        if (s2 !== peg$FAILED) {
1630
+          if (input.charCodeAt(peg$currPos) === 60) {
1631
+            s3 = peg$c15;
1632
+            peg$currPos++;
1651 1633
           } else {
1652 1634
             s3 = peg$FAILED;
1635
+            if (peg$silentFails === 0) { peg$fail(peg$c16); }
1653 1636
           }
1654 1637
           if (s3 !== peg$FAILED) {
1655
-            peg$savedPos = s0;
1656
-            s1 = peg$c92(s1);
1657
-            s0 = s1;
1638
+            s4 = peg$currPos;
1639
+            peg$silentFails++;
1640
+            s5 = peg$parsewhitespaces();
1641
+            if (s5 === peg$FAILED) {
1642
+              if (peg$c90.test(input.charAt(peg$currPos))) {
1643
+                s5 = input.charAt(peg$currPos);
1644
+                peg$currPos++;
1645
+              } else {
1646
+                s5 = peg$FAILED;
1647
+                if (peg$silentFails === 0) { peg$fail(peg$c91); }
1648
+              }
1649
+            }
1650
+            peg$silentFails--;
1651
+            if (s5 !== peg$FAILED) {
1652
+              peg$currPos = s4;
1653
+              s4 = void 0;
1654
+            } else {
1655
+              s4 = peg$FAILED;
1656
+            }
1657
+            if (s4 !== peg$FAILED) {
1658
+              peg$savedPos = s0;
1659
+              s1 = peg$c92(s2);
1660
+              s0 = s1;
1661
+            } else {
1662
+              peg$currPos = s0;
1663
+              s0 = peg$FAILED;
1664
+            }
1658 1665
           } else {
1659 1666
             peg$currPos = s0;
1660 1667
             s0 = peg$FAILED;
... ...
@@ -1736,30 +1743,47 @@ p2c2 = (function() {
1736 1743
     function peg$parsewhitespaces() {
1737 1744
       var s0, s1;
1738 1745
 
1739
-      if (peg$c100.test(input.charAt(peg$currPos))) {
1740
-        s0 = input.charAt(peg$currPos);
1741
-        peg$currPos++;
1742
-      } else {
1743
-        s0 = peg$FAILED;
1744
-        if (peg$silentFails === 0) { peg$fail(peg$c101); }
1745
-      }
1746
+      s0 = peg$parseinputStart();
1746 1747
       if (s0 === peg$FAILED) {
1747
-        s0 = peg$currPos;
1748
-        peg$silentFails++;
1749
-        if (input.length > peg$currPos) {
1750
-          s1 = input.charAt(peg$currPos);
1748
+        if (peg$c100.test(input.charAt(peg$currPos))) {
1749
+          s0 = input.charAt(peg$currPos);
1751 1750
           peg$currPos++;
1752 1751
         } else {
1753
-          s1 = peg$FAILED;
1754
-          if (peg$silentFails === 0) { peg$fail(peg$c1); }
1755
-        }
1756
-        peg$silentFails--;
1757
-        if (s1 === peg$FAILED) {
1758
-          s0 = void 0;
1759
-        } else {
1760
-          peg$currPos = s0;
1761 1752
           s0 = peg$FAILED;
1753
+          if (peg$silentFails === 0) { peg$fail(peg$c101); }
1762 1754
         }
1755
+        if (s0 === peg$FAILED) {
1756
+          s0 = peg$currPos;
1757
+          peg$silentFails++;
1758
+          if (input.length > peg$currPos) {
1759
+            s1 = input.charAt(peg$currPos);
1760
+            peg$currPos++;
1761
+          } else {
1762
+            s1 = peg$FAILED;
1763
+            if (peg$silentFails === 0) { peg$fail(peg$c1); }
1764
+          }
1765
+          peg$silentFails--;
1766
+          if (s1 === peg$FAILED) {
1767
+            s0 = void 0;
1768
+          } else {
1769
+            peg$currPos = s0;
1770
+            s0 = peg$FAILED;
1771
+          }
1772
+        }
1773
+      }
1774
+
1775
+      return s0;
1776
+    }
1777
+
1778
+    function peg$parseinputStart() {
1779
+      var s0;
1780
+
1781
+      peg$savedPos = peg$currPos;
1782
+      s0 = peg$c102();
1783
+      if (s0) {
1784
+        s0 = void 0;
1785
+      } else {
1786
+        s0 = peg$FAILED;
1763 1787
       }
1764 1788
 
1765 1789
       return s0;