perlSGML.1997Sep
view release on metacpan or search on metacpan
old/stripsgml view on Meta::CPAN
"Oacute", "O", # capital O, acute accent
"#211", "O",
"ocirc", "o", # small o, circumflex accent
"#244", "o",
"Ocirc", "O", # capital O, circumflex accent
"#212", "O",
"ograve", "o", # small o, grave accent
"#242", "o",
"Ograve", "O", # capital O, grave accent
"#210", "O",
"oslash", "o", # small o, slash
"#248", "o",
"Oslash", "O", # capital O, slash
"#216", "O",
"otilde", "o", # small o, tilde
"#245", "o",
"Otilde", "O", # capital O, tilde
"#213", "O",
"ouml", "o", # small o, dieresis or umlaut mark
"#246", "o",
"Ouml", "O", # capital O, dieresis or umlaut mark
"#214", "O",
"szlig", "s", # small sharp s, German (sz ligature)
"#223", "s",
"thorn", "p", # small thorn, Icelandic
"#254", "p",
"THORN", "P", # capital THORN, Icelandic
"#222", "P",
"uacute", "u", # small u, acute accent
"#250", "u",
"Uacute", "U", # capital U, acute accent
"#218", "U",
"ucirc", "u", # small u, circumflex accent
"#251", "u",
"Ucirc", "U", # capital U, circumflex accent
"#219", "U",
"ugrave", "u", # small u, grave accent
"#249", "u",
"Ugrave", "U", # capital U, grave accent
"#217", "U",
"uuml", "u", # small u, dieresis or umlaut mark
"#252", "u",
"Uuml", "U", # capital U, dieresis or umlaut mark
"#220", "U",
"yacute", "y", # small y, acute accent
"#253", "y",
"Yacute", "Y", # capital Y, acute accent
"#221", "Y",
"yuml", "y", # small y, dieresis or umlaut mark
"#255", "y",
);
##---------------------------------------------------------------------------##
## Globals
##---------------------------------------------------------------------------##
## Variable to hold current URL
$Url = '';
## Register callbacks to sgml.pl
$sgml'CdataFunc = "main'cdata_cb";
$sgml'OpenTagFunc = "main'open_tag_cb";
$sgml'EndTagFunc = "main'close_tag_cb";
##---------------------------------------------------------------------------##
##------------##
## Begin MAIN ##
##------------##
{
&get_cli_opts();
&SGMLread_sgml(STDIN);
exit 0;
}
##----------##
## End MAIN ##
##----------##
##---------------------------------------------------------------------------##
## Routines
##---------------------------------------------------------------------------##
sub get_cli_opts {
&Usage() unless
&NGetOpt(
"html", # Generate compact listing
"help" # Help message
);
&Usage() if defined($opt_help);
$HTML = 1 if defined($opt_html);
}
sub cdata_cb {
local(*data) = shift;
$data =~ s/\&([#\w-._]+);/&expand_ent($1)/ge;
print STDOUT $data;
}
sub open_tag_cb {
local($gi, $attr) = ($_[0], $_[1]);
if ($HTML && ($gi =~ /^A$/i)) {
if ($attr =~ /href\s*=\s*['"]([^'"]+)['"]/i) {
$Url = $1;
$Url = '' if $Url =~ /^#/; # Ignore relative URLs
} else {
$Url = '';
}
}
}
sub close_tag_cb {
local($gi) = ($_[0]);
if ($HTML && ($gi =~ /^A$/i) && $Url) {
print STDOUT " <URL:$Url>";
$Url = '';
}
}
sub expand_ent {
local($name) = shift;
defined($Entity{$name}) ? $Entity{$name} : "&$name;";
}
##---------------------------------------------------------------------------##
sub Usage {
print STDOUT <<EndOfUsage;
Usage: $PROG [<options>] < file.sgm > file.txt
Options:
-html : Preserve anchor URLs in output
-help : This message
Description:
stripsgml strips out SGML tags. Common entity references for special
characters are converted to ASCII. Input is read from standard in, and
output is sent to standard out.
Version: $VERSION
dtd.pl Version: $dtd'VERSION
Copyright (C) 1994-1996 Earl Hood, ehood\@medusa.acs.uci.edu
stripsgml comes with ABSOLUTELY NO WARRANTY and stripsgml may be copied
only under the terms of the GNU General Public License (version 2, or
later), which may be found in the distribution.
EndOfUsage
exit 0;
}
( run in 0.753 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )