]> gitweb.factorcode.org Git - factor.git/commitdiff
refactor farkup a bit, fix bug w/ paragraphs and code
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 25 Sep 2008 00:19:51 +0000 (19:19 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 25 Sep 2008 00:19:51 +0000 (19:19 -0500)
basis/farkup/farkup-tests.factor
basis/farkup/farkup.factor

index 42979007e88d246455a7125867fed2e66757a67a..f549e9c04cb276e5d8c1c5d537bba196f3224f6b 100644 (file)
@@ -135,3 +135,9 @@ link-no-follow? off
 
 [ "<hr/>" ] [ "___" convert-farkup ] unit-test
 [ "<hr/>\n" ] [ "___\n" convert-farkup ] unit-test
+
+[ "<p>before:\n<pre><span class='OPERATOR'>{</span> <span class='DIGIT'>1</span> <span class='DIGIT'>2</span> <span class='DIGIT'>3</span> <span class='OPERATOR'>}</span> <span class='DIGIT'>1</span> tail\n</pre></p>" ] 
+[ "before:\n[factor{{ 1 2 3 } 1 tail}]" convert-farkup ] unit-test
+[ "<a href='Factor'>Factor</a>-rific!" ]
+[ "[[Factor]]-rific" convert-farkup ] unit-test
index f482f8beaa2b6eece1fcac483585746dcde9f5ff..2957e6f2ecccca1eaeb69d6ae6d40e635b447e07 100644 (file)
@@ -40,6 +40,7 @@ EBNF: parse-farkup
 nl               = ("\r\n" | "\r" | "\n") => [[ drop "\n" ]]
 2nl              = nl nl
 
+
 heading1      = "=" (!("=" | nl).)+ "="
     => [[ second >string heading1 boa ]]
 
@@ -52,6 +53,10 @@ heading3      = "===" (!("=" | nl).)+ "==="
 heading4      = "====" (!("=" | nl).)+ "===="
     => [[ second >string heading4 boa ]]
 
+heading          = heading4 | heading3 | heading2 | heading1
+
+
+
 strong        = "*" (!("*" | nl).)+ "*"
     => [[ second >string strong boa ]]
 
@@ -67,8 +72,6 @@ subscript     = "~" (!("~" | nl).)+ "~"
 inline-code   = "%" (!("%" | nl).)+ "%"
     => [[ second >string inline-code boa ]]
 
-escaped-char  = "\" .                => [[ second 1string ]]
-
 link-content     = (!("|"|"]").)+
 
 image-link       = "[[image:" link-content  "|" link-content "]]"
@@ -84,11 +87,13 @@ labelled-link    = "[[" link-content "|" link-content "]]"
 
 link             = image-link | labelled-link | simple-link
 
-heading          = heading4 | heading3 | heading2 | heading1
+escaped-char  = "\" .                => [[ second 1string ]]
 
 inline-tag       = strong | emphasis | superscript | subscript | inline-code
                    | link | escaped-char
 
+
+
 inline-delimiter = '*' | '_' | '^' | '~' | '%' | '\' | '['
 
 cell             = (!(inline-delimiter | '|' | nl).)+
@@ -104,12 +109,13 @@ table            =  ((table-row nl => [[ first ]] )+ table-row? | table-row)
 text = (!(nl | code | heading | inline-delimiter | table ).)+
     => [[ >string ]]
 
-paragraph-item = (table | list | text | inline-tag | inline-delimiter)+
+paragraph-item = (table | list | code | text | inline-tag | inline-delimiter)+
 paragraph = ((paragraph-item nl => [[ first ]])+ nl+ => [[ first ]]
              | (paragraph-item nl)+ paragraph-item?
              | paragraph-item)
     => [[ paragraph boa ]]
 
+
 list-item     = (cell | inline-tag)*
 
 ordered-list-item      = '#' list-item
@@ -124,18 +130,23 @@ unordered-list = ((unordered-list-item nl)+ unordered-list-item? | unordered-lis
 
 list = ordered-list | unordered-list
 
+
 line = '___'
     => [[ drop line new ]]
 
-code       =  '[' (!('{' | nl | '[').)+ '{' (!("}]").)+ "}]"
+
+named-code       =  '[' (!('{' | nl | '[').)+ '{' (!("}]").)+ "}]"
     => [[ [ second >string ] [ fourth >string ] bi code boa ]]
 
 simple-code
            = "[{" (!("}]").)+ "}]"
     => [[ second f swap code boa ]]
 
+code = named-code | simple-code
+
+
 stand-alone
-           = (line | code | simple-code | heading | list | table | paragraph | nl)*
+           = (line | code | heading | list | table | paragraph | nl)*
 ;EBNF