! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs combinators destructors fry html io
io.backend io.pathnames io.styles kernel macros make math
-math.order math.parser namespaces sequences strings words
-splitting xml xml.syntax ;
+math.functions math.order math.parser namespaces sequences
+strings words splitting xml xml.syntax ;
IN: html.streams
GENERIC: url-of ( object -- url )
: hex-color, ( color -- )
[ red>> ] [ green>> ] [ blue>> ] tri
- [ 255 * >integer >hex 2 CHAR: 0 pad-head % ] tri@ ;
+ [ 255 * round >integer >hex 2 CHAR: 0 pad-head % ] tri@ ;
: fg-css, ( color -- )
"color: #" % hex-color, "; " % ;
: emit-html ( stream quot -- )
dip data>> push ; inline
-: icon-path ( path -- icons-path )
- "vocab:definitions/icons/" ?head [ "/icons/" prepend ] when ;
-
: img-tag ( xml style -- xml )
- image-style of [ nip icon-path simple-image ] when* ;
+ image-style of [ nip simple-image ] when* ;
: format-html-span ( string style stream -- )
[
: padding-css, ( padding -- )
first2 (padding-css,) ;
-CONSTANT: pre-css "white-space: pre; font-family: monospace;"
+: width-css, ( width -- )
+ "width: " % # "px; " % ;
: div-css-style ( style -- str )
+ [ span-css-style ]
[
{
{ page-color bg-css, }
{ border-color border-css, }
{ inset padding-css, }
+ { wrap-margin width-css, }
} make-css
- ] [ wrap-margin of [ pre-css append ] unless ] bi
- " display: inline-block;" append ;
+ ] bi "display: inline-block; " 3append ;
: div-tag ( xml style -- xml' )
div-css-style