]> gitweb.factorcode.org Git - factor.git/commitdiff
farkup: add horizontal lines as ___ (3 underlines)
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 23 Sep 2008 06:27:39 +0000 (01:27 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 23 Sep 2008 06:27:39 +0000 (01:27 -0500)
basis/farkup/farkup-tests.factor
basis/farkup/farkup.factor

index 5237774b046dc946e3d0dc8294b03add93fb827d..42979007e88d246455a7125867fed2e66757a67a 100644 (file)
@@ -132,3 +132,6 @@ link-no-follow? off
 [ "<p>asdf\n<ul><li>lol</li>\n<li>haha</li></ul></p>" ] [ "asdf\n-lol\n-haha" convert-farkup ] unit-test
 
 [ "<p>asdf</p><ul><li>lol</li>\n<li>haha</li></ul>" ] [ "asdf\n\n-lol\n-haha" convert-farkup ] unit-test
+
+[ "<hr/>" ] [ "___" convert-farkup ] unit-test
+[ "<hr/>\n" ] [ "___\n" convert-farkup ] unit-test
index 495e6d9b574760ca911bf7eddf58337152bbc2ba..f482f8beaa2b6eece1fcac483585746dcde9f5ff 100644 (file)
@@ -28,6 +28,7 @@ TUPLE: table-row child ;
 TUPLE: link href text ;
 TUPLE: image href text ;
 TUPLE: code mode string ;
+TUPLE: line ;
 
 : absolute-url? ( string -- ? )
     { "http://" "https://" "ftp://" } [ head? ] with contains? ;
@@ -123,6 +124,9 @@ unordered-list = ((unordered-list-item nl)+ unordered-list-item? | unordered-lis
 
 list = ordered-list | unordered-list
 
+line = '___'
+    => [[ drop line new ]]
+
 code       =  '[' (!('{' | nl | '[').)+ '{' (!("}]").)+ "}]"
     => [[ [ second >string ] [ fourth >string ] bi code boa ]]
 
@@ -131,7 +135,7 @@ simple-code
     => [[ second f swap code boa ]]
 
 stand-alone
-           = (code | simple-code | heading | list | table | paragraph | nl)*
+           = (line | code | simple-code | heading | list | table | paragraph | nl)*
 ;EBNF
 
 
@@ -193,6 +197,7 @@ M: paragraph (write-farkup) [ child>> (write-farkup) ] "p" in-tag. ;
 M: link (write-farkup) [ href>> ] [ text>> ] bi write-link ;
 M: image (write-farkup) [ href>> ] [ text>> ] bi write-image-link ;
 M: code (write-farkup) [ string>> ] [ mode>> ] bi render-code ;
+M: line (write-farkup) drop <hr/> ;
 M: table-row (write-farkup) ( obj -- )
     child>> [ [ [ (write-farkup) ] "td" in-tag. ] each ] "tr" in-tag. ;
 M: table (write-farkup) [ child>> (write-farkup) ] "table" in-tag. ;