1 ! Copyright (C) 2008 Alex Chapman
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors html.elements io io.streams.string kernel namespaces semantic-db sequences strings tangle.path ;
6 TUPLE: element attributes ;
8 TUPLE: ulist < element items ;
9 : <ulist> ( items -- element )
10 H{ } clone swap ulist boa ;
12 TUPLE: link < element href text ;
13 : <link> ( href text -- element )
14 H{ } clone -rot link boa ;
16 GENERIC: >html ( element -- str )
18 M: string >html ( str -- str ) ;
20 M: link >html ( link -- str )
21 [ <a dup href>> =href a> text>> write </a> ] with-string-writer ;
23 M: node >html ( node -- str )
25 swap node-content <link> >html
30 M: ulist >html ( ulist -- str )
32 <ul> items>> [ <li> >html write </li> ] each </ul>
33 ] with-string-writer ;