code>html ( dir file -- page )


Vocabulary
codebook

Inputs
diran object
filean object


Outputs
pagean object


Definition


:: code>html ( dir file -- page )
file name>> :> name "Generating HTML for " write name write
"..." print flush dir
[ file [ name>> ] [ encoding>> ] bi file-lines ]
with-directory :> lines lines length 1 +
number>string length :> line#len file mode>> load-mode
:> rules f lines [| l i |
l rules tokenize-line i 1 + line#len line#>string
htmlize-tokens
] map-index concat nip :> html-lines
H{ { "html-lines" html-lines } { "name" name } } T{ xml
{ prolog
T{ prolog { version "1.0" } { encoding "UTF-8" } }
}
{ before V{ T{ doctype-decl { name "html" } } " " } }
{ body
T{ tag
{ name
T{ name
{ space "" }
{ main "html" }
{ url "" }
}
}
{ children
V{
"\n "
~tag~
"\n "
~tag~
"\n "
}
}
}
}
{ after V{ "" } }
} interpolate-xml ;