]> gitweb.factorcode.org Git - factor.git/commitdiff
html.streams: allow non-equal padding values.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 11 Apr 2013 21:47:57 +0000 (14:47 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 11 Apr 2013 21:47:57 +0000 (14:47 -0700)
basis/html/streams/streams.factor

index 3e8f7c64a1496b431184ae99db42469b03fb206d..82f87f4f87eb01def9c1a93d05eb83d298b398fe 100644 (file)
@@ -101,8 +101,15 @@ M: html-span-stream dispose
 : border-css, ( border -- )
     "border: 1px solid #" % hex-color, "; " % ;
 
+: (padding-css,) ( horizontal vertical -- )
+    2dup = [
+        drop "padding: " % # "px; " %
+    ] [
+        "padding: " % # "px " % # "px; " %
+    ] if ;
+
 : padding-css, ( padding -- )
-    first2 "padding: " % # "px " % # "px; " % ;
+    first2 (padding-css,) ;
 
 CONSTANT: pre-css "white-space: pre; font-family: monospace;"
 
@@ -129,7 +136,7 @@ M: html-block-stream dispose
     end-sub-stream format-html-div ;
 
 : border-spacing-css, ( pair -- )
-    first2 max 2 /i "padding: " % # "px; " % ;
+    first2 [ 2 /i ] bi@ (padding-css,) ;
 
 : table-style ( style -- str )
     {