Handbook
Glossary
code>html ( dir file -- page )
Vocabulary
codebook
Inputs
dir
an
object
file
an
object
Outputs
page
an
object
Definition
USING:
accessors
io
io.directories
io.files
kernel
math
math.parser
sequences
xml.data
xml.syntax.private
xmode.catalog
xmode.marker
;
IN:
codebook
::
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
;