Last active
December 19, 2015 16:48
-
-
Save QueuingKoala/5985986 to your computer and use it in GitHub Desktop.
awk script to clean up openvpn.8 man2html output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# awk script for converting man2html openvpn output | |
{ | |
# Matching lines means we skip this many | |
if ( match($0, "^Content-type: ") ) skip=2 | |
if ( match($0, "Return to Main Contents") ) skip=1 | |
# Rip out the "Updated" date as it's wrong: | |
if ( match($0, "^Section: ") ) | |
sub("Updated: .*<BR>", "") | |
# replace localhost HREF <A> tags and their closing pair | |
if ( match($0, "<A HREF=\"http://localhost/.*\">") ) | |
{ | |
sub("<A HREF=\"http://localhost/.*\">", "") | |
sub("</A>", "") | |
} | |
# see if we need to skip lines. If not, print the buffer | |
if ( skip == 0 ) { print } | |
else { skip-- } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment