; inline
TUPLE: document
+quirks-mode?
tree
tree-insert-mode
doctype-token
tag-name
-end-tag-name
attribute-name
attribute-value
temporary-buffer
initial-mode >>tree-insert-mode
<doctype> >>doctype-token
SBUF" " clone >>tag-name
- SBUF" " clone >>end-tag-name
SBUF" " clone >>attribute-name
SBUF" " clone >>attribute-value
SBUF" " clone >>temporary-buffer
[ SBUF" " clone >>temporary-buffer drop ] bi ;
: emit-eof ( document -- ) drop "emit-eof" print ;
-: emit-char ( char document -- ) drop "emit-char:" write . ;
+: emit-char ( char document -- ) drop "emit-char: " write 1string . ;
: emit-temporary-buffer-with ( string document -- ) "emit-temp-buffer: " write temporary-buffer>> append . ;
-: emit-string ( char document -- ) drop "emit-string:" write . ;
-: emit-tag ( document -- ) "emit tag: " write . ;
+: emit-string ( char document -- ) drop "emit-string: " write . ;
+: emit-tag ( document -- )
+ "emit tag: " write
+ [ tag-name>> >string . ]
+ [ SBUF" " clone >>tag-name drop ] bi ;
: emit-end-tag ( document -- ) "emit end tag: " write . ;
: emit-doctype-token ( document -- )
"emit doctype: " write
next-char-from (bogus-comment-state) ;
-: (markup-declaration-open-state) ( document n/f string ch/f -- document n'/f string )
- drop {
+: markup-declaration-open-state ( document n/f string -- document n'/f string )
+ {
{ [ "--" take-from? ] [ comment-start-state ] }
{ [ "DOCTYPE" take-from-insensitive? ] [ doctype-state ] }
{ [ "[CDATA[" take-from-insensitive? ] [ unimplemented* ] }
]
} cond ;
-: markup-declaration-open-state ( document n/f string -- document n'/f string )
- next-char-from (markup-declaration-open-state) ;
-
-
: (comment-start-state) ( document n/f string ch/f -- document n'/f string )
{
{ [ dup CHAR: - = ] [ drop comment-start-dash-state ] }