         [ tag>> [ name>> >string ] [ name<< ] bi ]
         [ push-attribute ]
         [ tag>> . ]
+        [ dup tag>> tree-insert drop ]
         [ f >>tag drop ]
     } cleave ;
 : emit-end-tag ( document -- )

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 ;
IN: html5

: 1sbuf ( ch -- sbuf ) [ SBUF" " clone ] dip over push ; inline

: 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 ;

