USING: xmode.tokens xmode.marker xmode.catalog kernel html html.elements io io.files sequences words ; IN: xmode.code2html : htmlize-tokens ( tokens -- ) [ dup token-str swap token-id [ write ] [ write ] if* ] each ; : htmlize-line ( line-context line rules -- line-context' ) tokenize-line htmlize-tokens ; : htmlize-lines ( lines rules -- )
 f -rot [ htmlize-line nl ] curry each drop 
; : default-stylesheet ( -- ) ; : htmlize-file ( path -- ) dup lines dup empty? [ 2drop ] [ swap dup ".html" append [ [ dup write default-stylesheet over first find-mode load-mode htmlize-lines ] with-html-stream ] with-stream ] if ;