Scan the files in the current directory and wrap them into html/body tags so that netscape will display them as HTML and not as text.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #!/usr/local/bin/tclsh
# -*- tcl -*-
# Scan the files in the current directory and wrap them into html/body
# tags so that netscape will display them as HTML and not as text.
foreach f [glob *] {
if {[file extension $f] == ".html"} {continue}
if {[file isdirectory $f]} {continue}
set data [read [set fh [open $f r]]]
close $fh
set fh [open html/$f.html w]
puts $fh "<html><body>\n$data</body></html>"
close $fh
}
exit
|
Tags: text
Use HTML character entities. Wrapping arbitrary text files such that they can be displayed as html requires all '<', '>', '&', and '"' characters be converted to their HTML character entities: < > & "
This program accomplishes the conversion.
Usage: txt2html foo.bar > output.html