EnderUNIX tips
Mail to My Friend
,
Home Page
[
Console ]
"Convert TEXT2HTML" - Ülkü SAYILAN - (2004-08-23 11:39:20) [3396]
Convert TEXT2HTML
Ever felt the need to convert a text file to html?
Create a file named txt2html with the following contents
# Always start the output with
#an html header
BEGIN {print ""
print ""
# use the name of the inputfile
# as title
print "" FILENAME ""
print ""
# The text is formatted
# already, so use
print ""}
# lines consisting of a number
# of dashes (more than 1) are
# replaced by a
/^---*$/ {print " "; next}
# lines consisting of a number of equalsigns are replaced
# by a thick
/^===*$/ {print " "; next}
# less than and greater than
# sign must me replaced by tags.
{gsub("<","\<")
gsub(">","\>")
# Replace form feeds by a
# couple of empty lines
gsub("^L"," \ \ \ ")
print}
# At the end of the output,
# we must add some closing tags.
END {print " "}
Make this executable
(chmod a+x txt2html) and you're
ready to start converting your test files.
txt2html something.txt > something.html
Mail to My Friend
,
Home Page
|