parent
0d6096df0a
commit
404aa1bc92
|
@ -1,8 +1,9 @@
|
||||||
! Copyright (C) 2004, 2009 Slava Pestov.
|
! Copyright (C) 2004, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs combinators destructors fry html io
|
USING: accessors assocs combinators destructors fry html io
|
||||||
io.styles kernel macros make math math.parser sequences
|
io.backend io.pathnames io.styles kernel macros make math
|
||||||
splitting strings xml.syntax ;
|
math.order math.parser namespaces sequences strings words
|
||||||
|
splitting xml xml.syntax ;
|
||||||
IN: html.streams
|
IN: html.streams
|
||||||
|
|
||||||
GENERIC: url-of ( object -- url )
|
GENERIC: url-of ( object -- url )
|
||||||
|
@ -12,21 +13,20 @@ M: object url-of drop f ;
|
||||||
TUPLE: html-writer data ;
|
TUPLE: html-writer data ;
|
||||||
INSTANCE: html-writer output-stream
|
INSTANCE: html-writer output-stream
|
||||||
|
|
||||||
: <html-writer> ( -- html-writer )
|
|
||||||
html-writer new V{ } clone >>data ;
|
|
||||||
|
|
||||||
: with-html-writer ( quot -- xml )
|
|
||||||
<html-writer> [ swap with-output-stream* ] keep data>> ; inline
|
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
TUPLE: html-sub-stream < style-stream parent ;
|
: new-html-writer ( class -- html-writer )
|
||||||
|
new V{ } clone >>data ; inline
|
||||||
|
|
||||||
|
TUPLE: html-sub-stream < html-writer style parent ;
|
||||||
|
|
||||||
: new-html-sub-stream ( style stream class -- stream )
|
: new-html-sub-stream ( style stream class -- stream )
|
||||||
[ <html-writer> ] 3dip boa ; inline
|
new-html-writer
|
||||||
|
swap >>parent
|
||||||
|
swap >>style ; inline
|
||||||
|
|
||||||
: end-sub-stream ( substream -- string style stream )
|
: end-sub-stream ( substream -- string style stream )
|
||||||
[ stream>> data>> ] [ style>> ] [ parent>> ] tri ;
|
[ data>> ] [ style>> ] [ parent>> ] tri ;
|
||||||
|
|
||||||
: object-link-tag ( xml style -- xml )
|
: object-link-tag ( xml style -- xml )
|
||||||
presented of [ url-of [ simple-link ] when* ] when* ;
|
presented of [ url-of [ simple-link ] when* ] when* ;
|
||||||
|
@ -173,10 +173,16 @@ M: html-writer make-cell-stream
|
||||||
M: html-writer stream-write-table
|
M: html-writer stream-write-table
|
||||||
[
|
[
|
||||||
table-style swap [
|
table-style swap [
|
||||||
[ stream>> data>> [XML <td valign="top" style=<->><-></td> XML] ] with map
|
[ data>> [XML <td valign="top" style=<->><-></td> XML] ] with map
|
||||||
[XML <tr><-></tr> XML]
|
[XML <tr><-></tr> XML]
|
||||||
] with map
|
] with map
|
||||||
[XML <table style="display: inline-table; border-collapse: collapse;"><-></table> XML]
|
[XML <table style="display: inline-table; border-collapse: collapse;"><-></table> XML]
|
||||||
] emit-html ;
|
] emit-html ;
|
||||||
|
|
||||||
M: html-writer dispose drop ;
|
M: html-writer dispose drop ;
|
||||||
|
|
||||||
|
: <html-writer> ( -- html-writer )
|
||||||
|
html-writer new-html-writer ;
|
||||||
|
|
||||||
|
: with-html-writer ( quot -- xml )
|
||||||
|
<html-writer> [ swap with-output-stream* ] keep data>> ; inline
|
||||||
|
|
Loading…
Reference in New Issue