 USING: accessors arrays assocs combinators
 combinators.short-circuit io io.encodings.utf8 io.files
 json.reader kernel math math.order memoize modern.slices
-prettyprint sequences strings suffix-arrays words ;
+prettyprint sequences sequences.extras strings suffix-arrays
+words ;
 IN: html5
 
 : 1sbuf ( ch -- sbuf ) [ SBUF" " clone ] dip over push ; inline

: push-doctype-system-identifier ( ch document -- )
    doctype>> system-identifier>> push ;

GENERIC: tree-insert* ( document obj tree-insertion-mode -- document )
M: initial-mode tree-insert*
    drop {
        { CHAR: \t [ ] }
        { CHAR: \n [ ] }
        { CHAR: \f [ ] }
        { CHAR: \r [ ] }
        { CHAR: \s [ ] }
        [ "initial-mode tree-insert*" unimplemented ]
    } case ;

M: before-html-mode tree-insert* drop unimplemented* ;
M: before-head-mode tree-insert* drop unimplemented* ;

: new-doctype-with-quirks ( document -- )
    <doctype> t >>quirks? >>doctype drop ;

TUPLE: tag self-closing? name attributes children end-tag ;

: <tag> ( -- tag )
    tag new
        SBUF" " clone >>name
        V{ } clone >>attributes
        V{ } clone >>children ;

TUPLE: end-tag self-closing? name attributes ;

