[Download] [Unix Scripts] [Send Feedback]


This is an AWK script that is useful when you want to convert a Text file to HTML, retaining the formatting and all the characters that are special to HTML. While this program is not best suited for Java/C/C++ source code, which can use some additional syntax highlighting, it is well suited for scripts and text files. In lieu of syntax highlighting, this script does support a few useful options, best described in the the script itself as a comment. This comment itself was formatted using this script.

Note: Tips for new AWK users.

# text2html
# This AWK script converts a text file to html so that the text can be
# included in an html page. In particular, it converts special HTML
# characters so that they can be displayed as they should.  This
# script does not do any syntax highlighting (unlike java2html
# programs), but it does support a few useful options as described in
# the usage below:
# Usage: text2html.awk [numeric=1] [nbsp=1] [url=1] [header=1|title=<title>] <file>
# nbsp      ----  Indiates that non-breaking spaces should be converted
#                 to &nbsp;. If nbsp is set, spaces are converted to &nbsp;
#                 tabs are converted to &#009; and a line break <br> is
#                 added to each line.
# url       ----  Indicates that URLs should be converted to hyperlinks.
#                 Following URL protocols are recognized, as defined by
#                 RFC 1738.
#                 http:// https:// mailto: ftp:// news: telnet:// gopher://
#                 nntp:// wais:// prospero:// 
#                 www. has been added to the list in conformance with most
#                 e-mail client software behavior.
# header    ----  Indicates that HTML header should be generated for the file.
#                 If a title is specified, header is implied. If header is
#                 specified and title is not, the filename is used as the
#                 title.
# title     ----  Indicates that an HTML header should be generated for the file,
#                 using the specified title.
# numeric   ----  Indicates that HTML numeric entities should not
#                 be converted. By default, HTML numeric entities, 
#                 represented as &#nnn; are html-converted, so that
#                 they will look like &#nnn; in the HTML representation, 
#                 rather than the HTML character they represent. For example,
#                 '&#041;' in the text file will look '&#041;' in the
#                 result of text2html by default, and as 'A' if numeric 
#                 is specified.
At this time, I have packed the script using another AWK script that I wrote for the purpose. You can use this packed version for FREE as per the terms set forth here. You can also purchase the original source code with all the comments for $5 by clicking here.

Amazon Honor System Click Here to Pay Learn More