]> gitweb.factorcode.org Git - factor.git/commitdiff
add line-breaks? flag to farkup just for kicks. it might be useful
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 1 Oct 2008 22:11:19 +0000 (17:11 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 1 Oct 2008 22:11:19 +0000 (17:11 -0500)
basis/farkup/farkup.factor

index 73b0cba4d07469f24758016a05369bf117634d84..21e3c05d041bae54a89e9ea5bb6c403134ce9f9c 100644 (file)
@@ -9,6 +9,7 @@ IN: farkup
 SYMBOL: relative-link-prefix
 SYMBOL: disable-images?
 SYMBOL: link-no-follow?
+SYMBOL: line-breaks?
 
 TUPLE: heading1 child ;
 TUPLE: heading2 child ;
@@ -29,6 +30,7 @@ TUPLE: link href text ;
 TUPLE: image href text ;
 TUPLE: code mode string ;
 TUPLE: line ;
+TUPLE: line-break ;
 
 : absolute-url? ( string -- ? )
     { "http://" "https://" "ftp://" } [ head? ] with contains? ;
@@ -109,7 +111,9 @@ table            =  ((table-row nl => [[ first ]] )+ table-row? | table-row)
 text = (!(nl | code | heading | inline-delimiter | table ).)+
     => [[ >string ]]
 
-paragraph-nl-item = nl (list | line)?
+paragraph-nl-item = nl list
+    | nl line
+    | nl => [[ line-breaks? get [ drop line-break new ] when ]]
 paragraph-item = (table | code | text | inline-tag | inline-delimiter)+
 paragraph = ((paragraph-item paragraph-nl-item)+ nl+ => [[ first ]]
              | (paragraph-item paragraph-nl-item)+ paragraph-item?
@@ -209,6 +213,7 @@ 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: line-break (write-farkup) drop <br/> nl ;
 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. ;