*** empty log message ***
This commit is contained in:
parent
d8b2533102
commit
69f56860e8
73
src/filters/rclps
Executable file
73
src/filters/rclps
Executable file
@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
# @(#$Id: rclps,v 1.1 2005-02-02 17:57:08 dockes Exp $ (C) 2004 J.F.Dockes
|
||||
# Parts taken from Estraier:
|
||||
#================================================================
|
||||
# Estraier: a personal full-text search system
|
||||
# Copyright (C) 2003-2004 Mikio Hirabayashi
|
||||
#================================================================
|
||||
#================================================================
|
||||
# rclps
|
||||
# Extract text from a postscript file by executing pstotext or ps2ascii.
|
||||
#
|
||||
# The default is to use pstotext which can deal with accents.
|
||||
#
|
||||
# OTOH, ps2ascii is much faster, comes with ghostscript, and sometimes work
|
||||
# better (ie: on some openoffice output files).
|
||||
#
|
||||
#================================================================
|
||||
|
||||
|
||||
# set variables
|
||||
LANG=C ; export LANG
|
||||
LC_ALL=C ; export LC_ALL
|
||||
progname="rclpdf"
|
||||
decoder=pstotext
|
||||
#decoder=ps2ascii
|
||||
|
||||
# show help message
|
||||
if test $# -ne 1 -o "$1" = "--help"
|
||||
then
|
||||
printf 'Convert a postscript file to unformatted HTML text.\n'
|
||||
printf 'Usage: %s [infile]\n' "$progname"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
infile="$1"
|
||||
|
||||
# check the input file existence
|
||||
if test ! -f "$infile"
|
||||
then
|
||||
printf '%s: %s: no such file\n' "$progname" "$infile"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# output the result
|
||||
$decoder "$infile" |
|
||||
awk '
|
||||
BEGIN {
|
||||
printf("<html><head><title></title>\n")
|
||||
printf("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\n")
|
||||
printf("</head>\n<body><p>");
|
||||
esc = 1
|
||||
}
|
||||
{
|
||||
if ($0 ~ /-$/) {
|
||||
sub(/-$/, "", $0)
|
||||
printf("%s", $0);
|
||||
} else if($0 == "\f") {
|
||||
printf("</p>\n<hr>\n<p>")
|
||||
} else {
|
||||
if(esc > 0) {
|
||||
gsub(/&/, "\\&", $0)
|
||||
gsub(/</, "\\<", $0)
|
||||
gsub(/>/, "\\>", $0)
|
||||
}
|
||||
print $0
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("</p></body></html>\n");
|
||||
}' | iconv -f iso-8859-1 -t UTF-8 -c -s
|
||||
|
||||
# exit normally
|
||||
exit 0
|
||||
Loading…
x
Reference in New Issue
Block a user