]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorSlava Pestov <slava@goo.local>
Sun, 29 Mar 2009 03:19:04 +0000 (22:19 -0500)
committerSlava Pestov <slava@goo.local>
Sun, 29 Mar 2009 03:19:04 +0000 (22:19 -0500)
basis/farkup/farkup-tests.factor
basis/farkup/farkup.factor
basis/xmode/code2html/code2html-tests.factor
basis/xmode/marker/marker.factor

index cc379810ac255d6f2fd1c4a8dc7307b62dbc3afb..7cae523efba11908aa66759c4c5bf9388e18b656 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: farkup kernel peg peg.ebnf tools.test namespaces xml
-urls.encoding assocs xml.traversal xml.data ;
+urls.encoding assocs xml.traversal xml.data sequences random
+io continuations math ;
 IN: farkup.tests
 
 relative-link-prefix off
@@ -180,3 +181,29 @@ link-no-follow? off
 [ "<p><em>italics<strong>both</strong></em>after<strong></strong></p>" ] [ "_italics*both_after*" convert-farkup ] unit-test
 [ "<table><tr><td>foo|bar</td></tr></table>" ] [ "|foo\\|bar|" convert-farkup ] unit-test
 [ "<p></p>" ] [ "\\" convert-farkup ] unit-test
+
+! [ "<p>[abc]</p>" ] [ "[abc]" convert-farkup ] unit-test
+
+: random-markup ( -- string )
+    10 [
+        2 random 1 = [
+            {
+                "[["
+                "*"
+                "_"
+                "|"
+                "-"
+                "[{"
+                "\n"
+            } random
+        ] [
+            "abc"
+        ] if
+    ] replicate concat ;
+
+[ t ] [
+    100 [
+        drop random-markup
+        [ convert-farkup drop t ] [ drop print f ] recover
+    ] all?
+] unit-test
index 23a9023835b55e2bfa690e8b1ade3c74debd0970..41c6c4aa008f401c9f6f82a1b1b5bbd1669e5b10 100644 (file)
@@ -75,7 +75,7 @@ DEFER: (parse-paragraph)
         "|" split1
         [ "" like dup simple-link-title ] unless*
         [ "image:" ?head ] dip swap [ image boa ] [ parse-paragraph link boa ] if
-    ] dip [ (parse-paragraph) cons ] when* ;
+    ] dip [ (parse-paragraph) cons ] [ 1list ] if* ;
 
 : ?first ( seq -- elt ) 0 swap ?nth ;
 
@@ -187,7 +187,8 @@ DEFER: (parse-paragraph)
 : parse-code ( state -- state' item )
     dup 1 look CHAR: [ =
     [ unclip-slice make-paragraph ] [
-        "{" take-until [ rest ] dip
+        "{" take-until
+        [ rest ] dip
         "}]" take-until
         [ code boa ] dip swap
     ] if ;
index 241ab7ff75f0b466fc9e640571bbb4761ee52589..a35e6a2194c1229586de1dcacaad917cf3c9b686 100644 (file)
@@ -18,4 +18,8 @@ kernel io.streams.string xml.writer ;
     <" int x = "hi";
 /* a comment */ "> <string-reader> htmlize-stream
     write-xml
+] unit-test
+
+[ "<span class=\"MARKUP\">: foo</span> <span class=\"MARKUP\">;</span>" ] [
+    { ": foo ;" } "factor" htmlize-lines xml>string
 ] unit-test
\ No newline at end of file
index f584756f33c68f41323d4a4641ef578d84eb317b..98b4f91f86541ca0411f170edb40a33afc8f53b0 100755 (executable)
@@ -84,7 +84,7 @@ M: string-matcher text-matches?
     ] keep string>> length and ;
 
 M: regexp text-matches?
-    [ >string ] dip re-contains? ;
+    [ >string ] dip first-match to>> ;
 
 : rule-start-matches? ( rule -- match-count/f )
     dup start>> tuck swap can-match-here? [