This commit is contained in:
Serge Victor 2017-01-08 10:16:21 +07:00
parent 681bcd27a6
commit 6c4f76e7c9
29 changed files with 0 additions and 206809 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,397 +0,0 @@
#!/usr/bin/perl -W
# (P) & (C) 2006 by Peter Bieringer <pb at bieringer dot de>
# This program extracts URLs from a Lyx file and checks them
# 20060822/PB: major improvement, add support for persistent XML database
# 20081109/PB: enhancement to detect URLs in newer lyx file format
# 20090214/PB: detect IPv6 addresses in brackets and remove brackets, otherwise it won't work
# 20131112/PB: support newer Perl
use strict;
use Net::HTTP;
use Net::FTP;
use Net::NNTP;
use Crypt::SSLeay;
use LWP::UserAgent;
use XML::Dumper;
use Socket qw(NI_NUMERICSERV NI_NUMERICHOST getaddrinfo inet_pton);
my $debug = 0xffff & ~(0x20);
my %urls;
my $p_urls = \%urls;
my %hosts;
my $time = time;
my $dbfile;
my $dbfile_suffix = ".url-database.xml";
sub quote($) {
$_[0] =~ s/\`/#60/g;
$_[0] =~ s/[\200-\377]/\?/g;
return $_[0];
};
sub extract_urls($) {
my ($url, $desc);
print STDERR "DEBUG/extract_urls: open file: $_[0]\n";
open FILE, "<" . $_[0] || die "ERROR : can't open file: " . $_[0];
my $linecounter = 0;
while (<FILE>) {
$linecounter++;
chomp $_;
if ($_ =~ /LatexCommand \\url\[([^]]*)\]{([^}]*)}/) {
$desc = $1;
$url = $2;
print STDERR "DEBUG/extract_urls: desc='$desc' URL=$url\n" if ($debug & 0x10);
if (defined $$p_urls{$url}->{'line'}) {
print STDERR "DEBUG/extract_urls: URL already found earlier - skip\n" if ($debug & 0x10);
if ($$p_urls{$url}->{'time'} == $time) {
} else {
# from database, update now
$$p_urls{$url}->{'time'} = $time;
$$p_urls{$url}->{'line'} = $linecounter;
$$p_urls{$url}->{'desc'} = quote($desc);
};
next;
} else {
$$p_urls{$url}->{'desc'} = quote($desc);
$$p_urls{$url}->{'time'} = $time;
$$p_urls{$url}->{'line'} = $linecounter;
};
$url = "";
$desc = "";
} elsif ($_ =~ /name \"([^"]*)\"/) {
# name "IPv6 & Linux - HowTo"
$desc = $1;
} elsif ($_ =~ /target \"([^"]*)\"/) {
# target "http://www.bieringer.de/linux/IPv6/"
$url = $1;
print STDERR "DEBUG/extract_urls: desc='$desc' URL=$url\n" if ($debug & 0x10);
if (defined $$p_urls{$url}->{'line'}) {
print STDERR "DEBUG/extract_urls: URL already found earlier - skip\n" if ($debug & 0x10);
if ($$p_urls{$url}->{'time'} == $time) {
} else {
# from database, update now
$$p_urls{$url}->{'time'} = $time;
$$p_urls{$url}->{'line'} = $linecounter;
$$p_urls{$url}->{'desc'} = quote($desc);
};
next;
} else {
$$p_urls{$url}->{'desc'} = quote($desc);
$$p_urls{$url}->{'time'} = $time;
$$p_urls{$url}->{'line'} = $linecounter;
};
};
};
close(FILE);
};
sub load_urls() {
if (! -f $dbfile) {
print STDERR "DEBUG/load_urls: database file doesn't exist, skip load: $dbfile\n" if ($debug & 0x10);
return 2;
};
my $dump = new XML::Dumper;
print STDERR "DEBUG/load_urls: load database file: $dbfile\n" if ($debug & 0x10);
$p_urls = $dump->xml2pl($dbfile);
};
sub store_urls() {
my $dump = new XML::Dumper;
$dump->pl2xml($p_urls, $dbfile);
};
sub cleanup_old_urls() {
for my $url (keys %$p_urls) {
if ($$p_urls{$url}->{'time'} < $time) {
print STDERR "DEBUG/cleanup_old_urls: remove old URL from database: $url\n" if ($debug & 0x10);
my $p_h = $$p_urls{$url};
delete $$p_urls{$url};
};
};
};
sub check_ipv6only($$) {
print STDERR "DEBUG/check_ipv6only: begin\n" if ($debug & 0x10);
print STDERR "DEBUG/check_ipv6only: check: " . $_[0] . " on port " . $_[1] . "\n" if ($debug & 0x10);
my ($family, $socktype, $proto, $saddr, $canonname, @res, $err);
my ($host, $port);
$family = -1;
if ($_[0] =~ /^\[([0-9a-fA-F:]+)\]$/) {
# Strip [...]
$host = $1;
$port = $_[1];
print STDERR "DEBUG/check_ipv6only: host: " . $host . "\n" if ($debug & 0x10);
socket(Socket_Handle, PF_INET6, SOCK_STREAM, 0) || return 1;
$saddr = pack_sockaddr_in6($port, inet_pton(AF_INET6, $host));
connect(Socket_Handle, $saddr) && return 0;
close(Socket_Handle);
} else {
my %hints = ( socktype => SOCK_STREAM, family => AF_INET6);
($err, @res) = getaddrinfo($_[0], "echo", \%hints);
if (defined $err) {
print STDERR "ERROR/check_ipv6only: getaddrinfo fails: $err\n" if ($debug & 0x10);
return 1;
};
if (scalar(@res) < 5) {
print STDERR "ERROR/check_ipv6only: getaddrinfo fails\n" if ($debug & 0x10);
return 1;
};
$family = -1;
while (scalar(@res) >= 5) {
($family, $socktype, $proto, $saddr, $canonname, @res) = @res;
($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV);
print STDERR "Trying to connect to $host port $port...\n";
socket(Socket_Handle, $family, $socktype, $proto) || next;
connect(Socket_Handle, $saddr) && last;
close(Socket_Handle);
$family = -1;
};
if ($family != -1) {
print STDERR "connected to $host port $port\n";
close(Socket_Handle);
return 0;
} else {
warn "connect attempt failed\n";
return 1;
};
};
};
sub check_urls() {
print STDERR "DEBUG/check_urls: begin\n" if ($debug & 0x10);
for my $url (sort keys %$p_urls) {
if (defined $$p_urls{$url}->{'checktime'}) {
if ($$p_urls{$url}->{'checktime'} > $time - 60*60*24*7) {
if (defined $$p_urls{$url}->{'checkresult'} && $$p_urls{$url}->{'checkresult'} =~ /^ok/) {
# Checked during last 7 days - skip
print STDERR "DEBUG/check_urls: checked during last 7 days - skip: $url\n" if ($debug & 0x10);
next;
};
};
};
print STDERR "DEBUG/check_urls: check now: $url\n" if ($debug & 0x10);
my ($host, $port);
my $desc = $$p_urls{$url}->{'desc'};
my $status = "undef";
# Extract host
my ($proto, $hostport, $uri) = $url =~ /^([^:]+):\/\/([^\/]+)(.*)$/;
if ($hostport =~ /^([^:]):([0-9]+)$/) {
$host = $1;
$port = $2;
} else {
$host = $hostport;
if ($proto eq "http") {
$port = 80;
} elsif ($proto eq "ftp") {
$port = 21;
} elsif ($proto eq "nntp") {
$port = 119;
} elsif ($proto eq "https") {
$port = 443;
};
};
# Strip trailing #
$uri =~ s/#.*//;
if (length($uri) == 0) {
$status = "URI is empty";
goto ("LABEL_PRINT");
};
my $s;
if ($proto eq "ftp") {
# Check FTP
print STDERR "DEBUG/check_urls: open FTP connection: $host:$port\n" if ($debug & 0x20);
$s = Net::FTP->new(Host => $host, Port => $port, Timeout => 30, Passive => 1);
if (! defined $s) {
$status = "Host not found";
if (! check_ipv6only($host,$port)) {
$status = "ok (IPv6 only)";
};
goto ("LABEL_PRINT");
};
if (!$s->login("anonymous",'-anonymous@')) {
$status = "FTP anonymous login failed";
goto ("LABEL_PRINT");
};
if (!$s->cwd($uri)) {
$status = "FTP can't change to directory $uri";
goto ("LABEL_PRINT");
};
$status = "ok";
$s->quit;
} elsif ($proto eq "nntp") {
my $s = Net::NNTP->new(Host => $host, Timeout => 30);
if (! defined $s) {
$status = "Host not found";
if (! check_ipv6only($host,$port)) {
$status = "ok (IPv6 only)";
};
goto ("LABEL_PRINT");
};
$status = "ok";
$s->quit;
} elsif ($proto eq "https") {
my $ua = new LWP::UserAgent;
my $req = new HTTP::Request('HEAD', $url);
my $res = $ua->request($req);
my $code = $res->code;
if ($code !~ /^[23]/) {
$status = "HTTPS reports: $code";
} else {
$status = "ok";
};
} elsif ($proto eq "http") {
# Check HTTP
print STDERR "DEBUG/check_urls: open HTTP connection: $host:$port\n" if ($debug & 0x20);
$s = Net::HTTP->new(Host => $host, PeerPort => $port, Timeout => 30);
if (! defined $s) {
$status = "Host not found";
if (! check_ipv6only($host,$port)) {
$status = "ok (IPv6 only)";
};
goto ("LABEL_PRINT");
};
print STDERR "DEBUG/check_urls: send HEAD request: $uri\n" if ($debug & 0x20);
if ($s->write_request(HEAD => $uri, 'User-Agent' => "Mozilla/5.0") == 0) {
$status = "trouble with uri";
goto ("LABEL_PRINT");
};
print STDERR "DEBUG/check_urls: wait for response\n" if ($debug & 0x20);
my($code, $mess, %h) = $s->read_response_headers;
print STDERR "DEBUG/check_urls: check response\n" if ($debug & 0x10);
if ($code !~ /^[23]/) {
$status = "HTTP reports: $code";
} else {
$status = "ok";
};
};
LABEL_PRINT:
if ($status ne "ok") {
print "desc='$desc' URL=$url proto=$proto host=$host port=$port uri='$uri'";
print " status=$status\n\n";
die;
};
LABEL_END:
$$p_urls{$url}->{'checktime'} = $time;
$$p_urls{$url}->{'checkresult'} = $status;
undef $s;
store_urls();
};
};
sub report_urls() {
print STDERR "DEBUG/report_urls: begin\n" if ($debug & 0x10);
for my $url (sort { $$p_urls{$a}->{'line'} <=> $$p_urls{$b}->{'line'} } ( keys %$p_urls)) {
if ($$p_urls{$url}->{'checkresult'} =~ /^ok/) {
next;
};
print "NOTICE: URL has a problem: $url\n";
print " Description : " . $$p_urls{$url}->{'desc'} . "\n";
print " Line number : " . $$p_urls{$url}->{'line'} . "\n";
print " Result : " . $$p_urls{$url}->{'checkresult'} . "\n";
print "\n";
};
};
sub check_rfc_urls() {
print STDERR "DEBUG/check_rfc_urls: begin\n" if ($debug & 0x10);
for my $url (sort { $$p_urls{$a}->{'line'} <=> $$p_urls{$b}->{'line'} } ( keys %$p_urls)) {
if ($url =~ /rfc[0-9]{1,4}/) {
print "NOTICE: URL points to RFC: $url\n";
print " Description : " . $$p_urls{$url}->{'desc'} . "\n";
print " Line number : " . $$p_urls{$url}->{'line'} . "\n";
print "\n";
};
};
};
##### Main
if (! defined $ARGV[0] || $ARGV[0] eq "") {
die "Missing file name (arg1)";
};
if (! -f $ARGV[0]) {
die "Argument 1 is not an existing file: " . $ARGV[0];
};
$dbfile = $ARGV[0] . $dbfile_suffix;
load_urls();
extract_urls($ARGV[0]);
cleanup_old_urls();
check_urls();
store_urls();
check_rfc_urls();
report_urls();

View File

@ -1,35 +0,0 @@
#!/bin/sh
#
# $Id$
#
# Small helper script to copy SGML file to howto dir
#
# (P) & (C) by Peter Bieringer <pb at bieringer dot de>
#
# 20020119/PB: initial
FILE_SGML="Linux+IPv6-HOWTO.sgml"
DIRSRC="./"
DIRDST="../../howto/docbook/"
if [ ! -f "${DIRSRC}${FILE_SGML}" ]; then
echo "ERR : Missing SGML file '${DIRSRC}${FILE_SGML}'!"
exit 1
fi
if [ -f "${DIRDST}${FILE_SGML}" ]; then
if [ "${DIRDST}${FILE_SGML}" -nt "${DIRSRC}${FILE_SGML}" ]; then
echo "ERR : SGML file at destination is newer than source!"
exit 1
fi
fi
if [ -f "${DIRDST}${FILE_SGML}" ]; then
echo "INF : Remove old SGML file '${DIRDST}${FILE_SGML}'"
rm "${DIRDST}${FILE_SGML}"
fi
echo "INF : Copy new SGML file"
cp "${DIRSRC}${FILE_SGML}" "${DIRDST}${FILE_SGML}"

View File

@ -1,11 +0,0 @@
#!/bin/sh
# Generate all available howtos
list="Linux+IPv6-HOWTO.sgml Linux+IPv6-HOWTO.de.sgml Linux+IPv6-HOWTO.fr.sgml Linux+IPv6-HOWTO.pt_BR.sgml"
for lyx in $list; do
./generate.sh $lyx
done
echo -en "\a"

View File

@ -1,11 +0,0 @@
#!/bin/sh
# Generate all available howtos
list="Linux+IPv6-HOWTO.sgml Linux+IPv6-HOWTO.de.sgml"
for lyx in $list; do
./generate.sh $lyx $* || exit 1
done
echo -en "\a"

View File

@ -1,345 +0,0 @@
#!/bin/sh
#
# (P) & (C) 2003-2016 by Dr. Peter Bieringer <pb@bieringer.de>
#
# Generator script
#
# $Id$
#
# Requires: htmldoc recode docbook-utils-pdf
#
# Changelog
#
# 20020117/PB: review
# 20020128/PB: change PDF generation to LDP conform one, PS is still not LDP conform
# 20070401/PB: disable sgmlfixer (no longer needed)
# add support for XML file, replace nsgmls by onsgmls
# 20090214/PB: remove </?dummy> tag from SGML, onsgmls don't like it
# 20090523/PB: extend required binary check
# 20091220/PB: catch recode problem
# 20110508/PB: force UTF-8 as input format to fix mixed charset problems in HTML
# renice whole script
# support also ldp.dsl stored in same directory as the script
# 20110509/PB: add charset meta header on each html page to force UTF-8
# 20161215/PB: remove VGWort URL appender
loglevel=6
# parse options
while getopts "ql:" opt; do
case $opt in
q)
loglevel=4
;;
l)
loglevel=$OPTARG
echo "INFO : set loglevel to: $loglevel"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
shift $((OPTIND-1))
if [ -z "$1" ]; then
file_input="Linux+IPv6-HOWTO.sgml"
#file_input="Linux+IPv6-HOWTO.xml"
else
file_input="$1"
fi
if echo "$file_input" | grep -q ".sgml$"; then
# ok, SGML
true
elif echo "$file_input" | grep -q ".xml$"; then
# ok, XML
true
else
echo "ERR: file is not a SGML/XML file: $file_input"
exit 1
fi
if head -1 "$file_input" |grep -q DOCTYPE ; then
doctype="SGML"
elif head -1 "$file_input" |grep -q "xml version" ; then
doctype="XML"
else
echo "ERR: file is not a SGML file: $file_input"
exit 1
fi
echo "Used SGML file: $file_input"
file_base="${file_input%.*}"
ONSGMLS="/usr/bin/onsgmls"
JADE="/usr/bin/jade"
DB2PS="/usr/bin/db2ps"
DB2PDF="/usr/bin/db2pdf"
LDP_PRINT="/usr/local/bin/ldp_print"
PS2ASCII="/usr/bin/ps2ascii"
RECODE="/usr/bin/recode"
HTMLDOC="/usr/bin/htmldoc"
#LDP_PDFPS="yes"
checklist_bin="ONSGMLS JADE DB2PS DB2PDF PS2ASCII RECODE HTMLDOC"
if [ "$LDP_PDFPS" = "yes" ]; then
checklist_bin="$checklist_bin LDP_PRINT"
fi
file_ps="$file_base.ps"
file_pdf="$file_base.pdf"
file_txt="$file_base.txt"
file_html="$file_base.html"
file_ldpdsl="/usr/local/share/sgml/dsssl/ldp.dsl"
if [ ! -f $file_ldpdsl ]; then
# try local stored one
file_ldpdsl="`dirname $0`"
if [ "$file_ldpdsl" = "." ]; then
file_ldpdsl="`pwd`"
fi
file_ldpdsl="$file_ldpdsl/ldp.dsl"
fi
file_xmldcl="/usr/share/sgml/xml.dcl"
dir_dssslstylesheets="/usr/share/sgml/docbook/dsssl-stylesheets"
if [ ! -f "$file_ldpdsl" ]; then
echo "ERR: Missing DSL file: $file_ldpdsl"
exit 1
fi
if [ ! -f $file_input ]; then
echo "ERR: Missing SGML file, perhaps export DocBook of LyX won't work"
exit 1
fi
# look for required files
for f in $file_ldpdsl $file_xmldcl; do
if [ ! -e $f ]; then
echo "Missing file: $f"
exit 1
fi
done
# look for required binaries
for name in $checklist_bin; do
f="${!name}"
if [ ! -e $f ]; then
echo "Missing file: $f ($name)"
exit 1
fi
if [ ! -x $f ]; then
echo "Cannot executue: $f ($name)"
exit 1
fi
done
# run sgmlfix
#if [ -e ./runsgmlfix.sh ]; then
# ./runsgmlfix.sh "$file_input"
#else
# echo "WARN: cannot execute 'runsgmlfix.sh'"
#fi
export SP_ENCODING=UTF-8
export SP_CHARSET_FIXED=yes
## Functions
validate_sgml() {
# remove tags <dummy>, </dummy>
perl -pi -e 's|</?dummy>||g' "$file_input"
echo "INFO : Validate SGML/XML code '$file_input'"
if [ "$doctype" = "XML" ]; then
local options="$file_xmldcl"
fi
[ $loglevel -ge 7 ] && set -x
$ONSGMLS -s $options $file_input
local retval=$?
[ $loglevel -ge 7 ] && set +x
if [ $retval -gt 0 ]; then
echo "ERR: Validation results in errors!"
return 1
else
echo "INFO : Validation was successfully"
fi
}
create_html_multipage() {
echo "INFO : Create HTML multipages"
if [ ! -d "$file_base" ]; then
mkdir "$file_base" || exit 1
fi
pushd "$file_base" >/dev/null || exit 1
rm -f *
[ $loglevel -ge 7 ] && set -x
$JADE -t sgml -i html -D $dir_dssslstylesheets -d "${file_ldpdsl}#html" ../$file_input
local retval=$?
[ $loglevel -ge 7 ] && set +x
perl -pi -e 's#><META#><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"\n><META#o' *.html
local r=$?
if [ $r -ne 0 ]; then
retval=$?
fi
popd >/dev/null
return $retval
}
create_html_singlepage() {
echo "INFO : Create HTML singlepage '$file_html' from '$file_input'"
[ $loglevel -ge 7 ] && set -x
$JADE -t sgml -i html -V nochunks -d "${file_ldpdsl}#html" $file_input >$file_html
local retval=$?
[ $loglevel -ge 7 ] && set +x
perl -pi -e 's#><META#><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"\n><META#o' $file_html
local r=$?
if [ $r -ne 0 ]; then
retval=$?
fi
if [ $retval -eq 0 ]; then
echo "INFO : Create HTML singlepage - done"
else
echo "ERR: Create HTML singlepage - an error occurs!"
fi
return $retval
}
create_rtf() {
echo "INFO : Create RTF file '$file_rtf'"
[ $loglevel -ge 7 ] && set -x
$JADE -t rtf -d ${file_ldpdsl} $file_input
local retval=$?
[ $loglevel -ge 7 ] && set +x
if [ $retval -eq 0 ]; then
echo "INFO : Create RTF file - done"
else
echo "ERR: Create RTF file - an error occurs!"
fi
return $retval
}
create_ps() {
echo "INFO : Create PS file '$file_ps'"
[ $loglevel -ge 7 ] && set -x
$DB2PS --dsl ${file_ldpdsl} $file_input
local retval=$?
[ $loglevel -ge 7 ] && set +x
if [ $retval -eq 0 ]; then
echo "INFO : Create PS file - done"
else
echo "ERR: Create PS file - an error occurs!"
fi
return $retval
}
create_pdf() {
if [ "$LDP_PDFPS" = "yes" ]; then
# Use LDP conform mechanism
echo "INFO : Create PDF file (LDP conform) '$file_pdf' from HTML file '$file_html'"
if [ $file_html -ot $file_input ]; then
echo "ERR: Create PDF file - needed single page HTML file '$file_html' is older than original '$file_input'"
return 1
fi
[ $loglevel -ge 7 ] && set -x
$LDP_PRINT $file_html
local retval=$?
[ $loglevel -ge 7 ] && set +x
else
echo "INFO : Create PDF file (NOT LDP conform) '$file_pdf'"
[ $loglevel -ge 7 ] && set -x
$DB2PDF --dsl ${file_ldpdsl} $file_input
local retval=$?
[ $loglevel -ge 7 ] && set +x
fi
if [ $retval -eq 0 ]; then
echo "INFO : Create PDF file - done"
else
echo "ERR: Create PDF file - an error occurs!"
fi
return $retval
}
create_txt() {
echo "INFO : Create TXT file '$file_txt' from PS file '$file_ps'"
[ -f $file_txt ] && rm $file_txt
if [ -f $file_ps ]; then
echo "INFO : Create TXT file '$file_txt'"
[ $loglevel -ge 7 ] && set -x
$PS2ASCII $file_ps > $file_txt
local retval=$?
[ $loglevel -ge 7 ] && set +x
else
echo "ERR: Cannot create TXT because of missing PS file"
fi
if [ $retval -eq 0 ]; then
echo "INFO : Create TXT file - done"
else
echo "ERR: Create TXT file - an error occurs!"
fi
return $retval
}
### Main
validate_sgml
[ $? -ne 0 ] && exit 1
create_html_multipage
if [ $? -ne 0 ]; then
echo "ERROR : create_html_multipage was not successful"
exit 1
fi
create_html_singlepage
if [ $? -ne 0 ]; then
echo "ERROR : create_html_singlepage was not successful"
exit 1
fi
create_pdf
if [ $? -ne 0 ]; then
echo "ERROR : create_pdf was not successful"
exit 1
fi
#create_ps
#[ $? -ne 0 ] && exit 1
#create_txt
#[ $? -ne 0 ] && exit 1
#create_rtf
#[ $? -ne 0 ] && exit 1
## Add VGWort URL
#if [ -x ./adjust-html-vgwort.sh ]; then
# case $file_input in
# 'Linux+IPv6-HOWTO.sgml')
# echo "NOTICE: add vgwort URL"
# ./adjust-html-vgwort.sh en
# ;;
# 'Linux+IPv6-HOWTO.de.sgml')
# echo "NOTICE: add vgwort URL"
# ./adjust-html-vgwort.sh de
# ;;
# esac
#else
# echo "NOTICE : can't add vgwort URL (missing adjust-html-vgwort.sh)"
#fi
exit 0

View File

@ -1,30 +0,0 @@
# $Id$
This is the working directory of
Peter Bieringer
pb (at) bieringer.de
Content:
Linux+IPv6-HOWTO.lyx (online next)
LyX file of the Linux+IPv6-HOWTO
lyxcodelinewrapper.pl
Perl program which wraps too long "code" lines in a LyX file
sgmllyxtabletagfix.pl
Perl program which fixes table tags
sgmllyxquotefix.pl
Perl program which fixes quote tags
copytohowtodir.sh
Shell program which copy SGML file to local howto directory
runsgmlfix.sh
Shell program which runs all the SGML code fix programs
generate.sh
Shell program which run different generation steps (needed for local review)
requires: sgml-common opensp openjade docbook-utils-pdf recode htmldoc
2009 Test

View File

@ -1,351 +0,0 @@
<!DOCTYPE style-sheet PUBLIC
"-//James Clark//DTD DSSSL Style Sheet//EN" [
<!ENTITY % html "IGNORE">
<![%html;[
<!ENTITY % print "IGNORE">
<!ENTITY docbook.dsl PUBLIC
"-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN"
CDATA dsssl>
]]>
<!ENTITY % print "INCLUDE">
<![%print;[
<!ENTITY docbook.dsl PUBLIC
"-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"
CDATA dsssl>
]]>
]>
<style-sheet>
<style-specification id="print" use="docbook">
<style-specification-body>
;; customize the print stylesheet
(declare-characteristic preserve-sdata?
;; this is necessary because right now jadetex does not understand
;; symbolic entities, whereas things work well with numeric entities.
"UNREGISTERED::James Clark//Characteristic::preserve-sdata?"
#f)
(define %generate-article-toc%
;; Should a Table of Contents be produced for Articles?
#t)
(define (toc-depth nd)
4)
(define %generate-article-titlepage-on-separate-page%
;; Should the article title page be on a separate page?
#t)
(define %section-autolabel%
;; Are sections enumerated?
#t)
(define %footnote-ulinks%
;; Generate footnotes for ULinks?
#f)
(define %bop-footnotes%
;; Make "bottom-of-page" footnotes?
#f)
(define %body-start-indent%
;; Default indent of body text
0pi)
(define %para-indent-firstpara%
;; First line start-indent for the first paragraph
0pt)
(define %para-indent%
;; First line start-indent for paragraphs (other than the first)
0pt)
(define %block-start-indent%
;; Extra start-indent for block-elements
0pt)
(define formal-object-float
;; Do formal objects float?
#t)
(define %hyphenation%
;; Allow automatic hyphenation?
#t)
(define %admon-graphics%
;; Use graphics in admonitions?
#f)
(define %default-quadding%
;; Full justification.
'justify)
(define (book-titlepage-verso-elements)
;;added publisher, releaseinfo to the default list
(list (normalize "title")
(normalize "subtitle")
(normalize "corpauthor")
(normalize "authorgroup")
(normalize "author")
(normalize "publisher")
(normalize "releaseinfo")
(normalize "editor")
(normalize "edition")
(normalize "pubdate")
(normalize "copyright")
(normalize "isbn")
(normalize "abstract")
(normalize "legalnotice")
(normalize "revhistory")))
</style-specification-body>
</style-specification>
<!--
;; customize the html stylesheet; parts borrowed from
;; Cygnus at http://sourceware.cygnus.com/ (cygnus-both.dsl)
-->
<style-specification id="html" use="docbook">
<style-specification-body>
(declare-characteristic preserve-sdata?
;; this is necessary because right now jadetex does not understand
;; symbolic entities, whereas things work well with numeric entities.
"UNREGISTERED::James Clark//Characteristic::preserve-sdata?"
#f)
(declare-flow-object-class element
;; for redhat
"UNREGISTERED::James Clark//Flow Object Class::element")
(define %html-pubid%
;; put the public identifier in each HTML file
"-//W3C//DTD HTML 4.0 Transitional//EN")
(define %generate-legalnotice-link%
;; put the legal notice in a separate file
#t)
(define %admon-graphics-path%
;; use graphics in admonitions, set their
"../images/")
(define %admon-graphics%
#t)
(define %funcsynopsis-decoration%
;; make funcsynopsis look pretty
#t)
(define %html-ext%
;; when producing HTML files, use this extension
".html")
(define %generate-book-toc%
;; Should a Table of Contents be produced for books?
#t)
(define %generate-article-toc%
;; Should a Table of Contents be produced for articles?
#t)
(define %generate-part-toc%
;; Should a Table of Contents be produced for parts?
#t)
(define %generate-book-titlepage%
;; produce a title page for books
#t)
(define %generate-article-titlepage%
;; produce a title page for articles
#t)
(define (chunk-skip-first-element-list)
;; forces the Table of Contents on separate page
'())
(define (list-element-list)
;; fixes bug in Table of Contents generation
'())
(define %root-filename%
;; The filename of the root HTML document (e.g, "index").
"index")
(define %shade-verbatim%
;; verbatim sections will be shaded if t(rue)
#t)
(define %use-id-as-filename%
;; Use ID attributes as name for component HTML files?
#t)
(define %graphic-extensions%
;; graphic extensions allowed
'("gif" "png" "jpg" "jpeg" "tif" "tiff" "eps" "epsf" ))
(define %graphic-default-extension%
"gif")
(define %section-autolabel%
;; For enumerated sections (1.1, 1.1.1, 1.2, etc.)
#t)
(define (toc-depth nd)
;; more depth (2 levels) to toc; instead of flat hierarchy
2)
(element emphasis
;; make role=strong equate to bold for emphasis tag
(if (equal? (attribute-string "role") "strong")
(make element gi: "STRONG" (process-children))
(make element gi: "EM" (process-children))))
(define (book-titlepage-recto-elements)
;; elements on a book's titlepage
(list (normalize "title")
(normalize "subtitle")
(normalize "graphic")
(normalize "mediaobject")
(normalize "corpauthor")
(normalize "authorgroup")
(normalize "author")
(normalize "othercredit")
(normalize "contrib")
(normalize "edition")
(normalize "releaseinfo")
(normalize "publisher")
(normalize "editor")
(normalize "copyright")
(normalize "pubdate")
(normalize "revhistory")
(normalize "abstract")
(normalize "legalnotice")))
(define (article-titlepage-recto-elements)
;; elements on an article's titlepage
(list (normalize "title")
(normalize "subtitle")
(normalize "authorgroup")
(normalize "author")
(normalize "othercredit")
(normalize "releaseinfo")
(normalize "copyright")
(normalize "pubdate")
(normalize "revhistory")
(normalize "abstract")
(normalize "legalnotice")))
(define (process-contrib #!optional (sosofo (process-children)))
;; print out with othercredit information; for translators, etc.
(make sequence
(make element gi: "SPAN"
attributes: (list (list "CLASS" (gi)))
(process-children))))
(define (process-othercredit #!optional (sosofo (process-children)))
;; print out othercredit information; for translators, etc.
(let ((author-name (author-string))
(author-contrib (select-elements (children (current-node))
(normalize "contrib"))))
(make element gi: "P"
attributes: (list (list "CLASS" (gi)))
(make element gi: "B"
(literal author-name)
(literal " - "))
(process-node-list author-contrib))))
(mode article-titlepage-recto-mode
(element contrib (process-contrib))
(element othercredit (process-othercredit))
)
(mode book-titlepage-recto-mode
(element contrib (process-contrib))
(element othercredit (process-othercredit))
)
(define (article-title nd)
(let* ((artchild (children nd))
(artheader (select-elements artchild (normalize "artheader")))
(artinfo (select-elements artchild (normalize "articleinfo")))
(ahdr (if (node-list-empty? artheader)
artinfo
artheader))
(ahtitles (select-elements (children ahdr)
(normalize "title")))
(artitles (select-elements artchild (normalize "title")))
(titles (if (node-list-empty? artitles)
ahtitles
artitles)))
(if (node-list-empty? titles)
""
(node-list-first titles))))
(mode subtitle-mode
;; do not print subtitle on subsequent pages
(element subtitle (empty-sosofo)))
;; Redefinition of $verbatim-display$
;; Origin: dbverb.dsl
;; Different foreground and background colors for verbatim elements
;; Author: Philippe Martin (feloy@free.fr) 2001-04-07
(define ($verbatim-display$ indent line-numbers?)
(let ((verbatim-element (gi))
(content (make element gi: "PRE"
attributes: (list
(list "CLASS" (gi)))
(if (or indent line-numbers?)
($verbatim-line-by-line$ indent line-numbers?)
(process-children)))))
(if %shade-verbatim%
(make element gi: "TABLE"
attributes: (shade-verbatim-attr-element verbatim-element)
(make element gi: "TR"
(make element gi: "TD"
(make element gi: "FONT"
attributes: (list
(list "COLOR" (car (shade-verbatim-element-colors
verbatim-element))))
content))))
content)))
;;
;; Customize this function
;; to change the foreground and background colors
;; of the different verbatim elements
;; Return (list "foreground color" "background color")
;;
(define (shade-verbatim-element-colors element)
(case element
(("SYNOPSIS") (list "#000000" "#6495ED"))
;; ...
;; Add your verbatim elements here
;; ...
(else (list "#000000" "#E0E0E0"))))
(define (shade-verbatim-attr-element element)
(list
(list "BORDER"
(cond
((equal? element (normalize "SCREEN")) "1")
(else "0")))
(list "BGCOLOR" (car (cdr (shade-verbatim-element-colors element))))
(list "WIDTH" ($table-width$))))
;; End of $verbatim-display$ redefinition
</style-specification-body>
</style-specification>
<external-specification id="docbook" document="docbook.dsl">
</style-sheet>

View File

@ -1,173 +0,0 @@
#!/usr/bin/perl
#
# $Id$
#
# LyX codeline wrapper tool
#
# (P) & (C) 2002-2009 by Peter Bieringer <pb@bieringer.de>
#
# Published under the GNU GPL licence
#
# Takes LyX code from stdin and pipes a modified to stdout.
# Wraps length of code lines to a given limit.
# Marks second and next lines with a given character.
#
# Attention: no warranty that the new LyX code is very well!
# Use diff to check proper work
#
# Changes:
# 20020118: Initial try
# 20020119: Improve tool, do not touch code lines including LyX tags
# 20090214/PB: adjustments for LyX format 345
#
# Known bugs:
# * Sure some
#
# Known limitations:
# * Code lines containing LyX tags are currently not supported and skipped
my $lyx_format_supported = "474";
sub print_long_line ($);
my $TAG_CODE = 0;
my $line_carry = "";
my $lines_original = "";
my $line_limit = 79;
#my $linebreakchar = chr(172);
my $linebreakchar = "¬"; # UTF-8 support
#my $debug = 1;
my $debug = 0;
while (<STDIN>) {
my $line = $_;
chomp $line;
#print "$line";
#print "\n";
#
if ($line =~ /^\\lyxformat ([0-9]+)$/) {
if ($1 ne $lyx_format_supported) {
die "Lyx format not supported: $1";
};
} elsif ($line =~ /^\\begin_layout Code$/ && $TAG_CODE != 1) {
print STDERR "INF: Code tag starts\n";
$TAG_CODE = 1;
$line_carry = "";
$lines_original = "";
next;
} elsif ($line =~ /^\\end_layout$/ && $TAG_CODE == 1) {
print STDERR "INF: Code tag ends\n";
if ($lines_original =~ /\\/) {
# Ooops, lines contain a LyX tag, currently not supported, so let it be
#print STDERR "WARN: Lines contain LyX code tag, let it like it is\n: '$lines_original'";
print STDERR "WARN: Lines contain LyX code tag, let it like it is\n";
if ($debug & 0x01) { print "G"; };
print "\\begin_layout Code" . "\n" . $lines_original . "\\end_layout" . "\n";
} elsif ($lines_original =~ /$linebreakchar/) {
# Code line already wrapped
print STDERR "INF: Code line already wrapped, let it like it is\n";
if ($debug & 0x01) { print "F"; };
print "\\begin_layout Code" . "\n" . $lines_original . "\\end_layout" . "\n";
} else {
print_long_line $line_carry;
};
$TAG_CODE = 0;
$line_carry = "";
$lines_original = "";
next;
} elsif ($line =~ /^\\layout/ && $TAG_CODE == 1) {
die "unsupported";
print STDERR "INF: Code tag ends\n";
if ($lines_original =~ /\\/) {
# Ooops, lines contain a LyX tag, currently not supported, so let it be
#print STDERR "WARN: Lines contain LyX code tag, let it like it is\n: '$lines_original'";
print STDERR "WARN: Lines contain LyX code tag, let it like it is\n";
if ($debug & 0x01) { print "A"; };
print "\\begin_layout Code" . "\n" . $lines_original;
} elsif ($lines_original =~ /$linebreakchar/) {
# Code line already wrapped
print STDERR "INF: Code line already wrapped, let it like it is\n";
if ($debug & 0x01) { print "B"; };
print "\\begin_layout Code" . "\n" . $lines_original;
} else {
print_long_line $line_carry;
};
$line_carry = "";
$lines_original = "";
$TAG_CODE = 0;
print $line . "\n";
next;
};
if ($TAG_CODE != 1) {
print $line . "\n";
} else {
$lines_original .= $line . "\n";
if ($line eq "") {
# empty lines are skipped here
next;
};
print STDERR "INF: Found code line: '" . $line . "'\n";
$line_carry .= $line;
};
};
sub print_long_line ($){
my $line = shift;
print STDERR "INF: Print code line: '" . $line . "'\n";
my $l = 0;
my $c = "";
if (length($line) == 0) {
if ($debug & 0x01) { print "C"; };
my $s = "\\begin_layout Code" . "\n" . "\n" . "\\end_layout" . "\n";
print $s;
return;
};
while ($l < length($line)) {
my $t = 0;
print STDERR "INF: Step: $l\n";
if ($l == 0) {
$c = "";
} else {
$c =$linebreakchar;
}
if (length($line) - $l <= $line_limit) {
if ($debug & 0x01) { print "D"; };
my $s = "\\begin_layout Code" . "\n" . $c . substr($line, $l) . "\n" . "\\end_layout" . "\n";
print STDERR "INF: Step end\n";
print $s;
print STDERR $s;
last;
};
for ($t = $line_limit; $t > 0; $t--) {
if (substr($line, $l + $t, 1) eq " ") {
print STDERR "INF: Found <space> at pos: $t\n";
last;
};
};
if ($t == 0) { $t = $line_limit };
print STDERR "INF: Start printing l=$l t=$t\n";
if ($debug & 0x01) { print "E"; };
my $s = "\\begin_layout Code" . "\n" . $c . substr($line, $l, $t) . "\n" . "\\end_layout" . "\n\n";
print $s;
print STDERR $s;
$l = $l + $t;
};
};
print STDERR "\n\nWARNING: check code using utility 'diff' for proper LyX output!\n";

View File

@ -1,335 +0,0 @@
#!/bin/bash
#
# (P) & (C) 2011 - 2011 by Dr. Peter Bieringer <pb@bieringer.de>
#
# Wrapper script for HOWTO generator script
#
# Requires: "generate.sh"
#
# Changelog
#
#
# 20110511/PB: use absolute paths, extend error checking
URL_BASE="http://cvs.tldp.org/go.to/LDP/LDP/users/Peter-Bieringer/"
FILE_EN="Linux+IPv6-HOWTO.sgml"
FILE_DE="Linux+IPv6-HOWTO.de.sgml"
FILE_FR="Linux+IPv6-HOWTO.fr.sgml"
FILE_PT_BR="Linux+IPv6-HOWTO.pt_BR.sgml"
options_wget="--quiet"
DIR_BASE="$HOME/howtos"
DIR_DOWNLOAD="$HOME/howtos/download"
DIR_DEST_BASE="/var/www/html/howtos"
## logging
log() {
local level="$1"
shift
printf "%-6s: %s\n" "$level" "$*"
}
## download file
download() {
local url_base="$1"
local file="$2"
if [ -z "$url_base" ]; then
log "ERROR" "'url_base' empty"
return 1
fi
if [ -z "$file" ]; then
log "ERROR" "'file' empty"
return 1
fi
if [ -z "$DIR_DOWNLOAD" ]; then
log "ERROR" "no download directory given"
return 1
fi
if [ ! -d "$DIR_DOWNLOAD" ]; then
log "ERROR" "download directory doesn't exist: $DIR_DOWNLOAD"
return 1
fi
if [ "$force_download" != "1" ]; then
log "NOTICE" "skip download $url_base/$file (use option -d)"
return 0
fi
log "INFO" "start download $url_base/$file to directory $DIR_DOWNLOAD"
wget $options_wget -N -P "$DIR_DOWNLOAD" "$url_base/$file"
local result=$?
if [ $result -eq 0 ]; then
log "INFO" "download successful: $url_base/$file (stored to $DIR_DOWNLOAD)"
else
log "ERROR" "download not successful: $url_base/$file"
fi
return $result
}
## check, whether processing should be started
check() {
local file_download="$1"
local file="$2"
local dir_html="$3"
if [ -z "$file" ]; then
log "ERROR" "'file' empty"
return 1
fi
if [ -z "$file_download" ]; then
log "ERROR" "'file_download' empty"
return 1
fi
if [ -z "$dir_html" ]; then
log "ERROR" "'dir_html' empty"
return 1
fi
log "INFO" "check file: $file"
if [ ! -f "$file_download" ]; then
log "WARN" "no downloaded file available: $file_download"
return 1
fi
if [ ! -f "$file" ]; then
log "NOTICE" "no 'old' file available: $file (copy now)"
cp -p "$file_download" "$file"
if [ $? -ne 0 ]; then
log "ERROR" "can't copy 'new' file to 'old' file: $file_download -> $file"
return 1
fi
return 0
else
if cmp -s "$file_download" "$file"; then
log "INFO" "'old' is identical with 'new' file: $file"
else
log "NOTICE" "'old' is not equal with 'new' file: $file"
cp -p "$file_download" "$file"
if [ $? -ne 0 ]; then
log "ERROR" "can't copy 'new' file to 'old' file: $file_download -> $file"
return 1
fi
return 0
fi
# check contents of destination directory
log "INFO" "check directory: $dir"
if [ ! -d "$dir" ]; then
log "NOTICE" "directory still not exist: $dir"
return 0
fi
local num_files="`find "$dir" -mindepth 1 -maxdepth 1 -type f | wc -l`"
if [ $num_files -eq 0 ]; then
# directory is empty
log "NOTICE" "directory is empty: $dir"
return 0
fi
local num_files_old="`find "$dir" -mindepth 1 -maxdepth 1 -type f ! -newer "$file" | wc -l`"
if [ $num_files_old -ne 0 ]; then
# force regeneration
log "NOTICE" "directory contains old files: $dir ($num_files_old)"
return 0
fi
# 'old' file already exists
if [ "$file" -nt "$file_download" ]; then
log "WARN" "'old' is newer than 'new' file: $file"
return 1
fi
fi
if [ "$force_generate" = "1" ]; then
log "NOTICE" "force regeneration of: $file"
return 0
fi
# nothing to do
log "DEBUG" "no indication for start processing file found: $file"
return 1
}
## process/generate output
process() {
log "INFO" "start processing file: $file"
pushd $DIR_BASE >/dev/null || return 1
./generate.sh "$file"
local result=$?
popd >/dev/null
if [ $result -ne 0 ]; then
log "ERROR" "processing of file not successful: $file"
return 1
fi
log "INFO" "processing of file successful: $file"
}
## copy output
copy() {
local file="$1"
if [ -z "$DIR_DEST_BASE" ]; then
log "ERROR" "destination directory for output not given 'DIR_DEST_BASE'"
fi
if [ ! -d "$DIR_DEST_BASE" ]; then
log "ERROR" "destination directory for output doesn't exist: $DIR_DEST_BASE"
return 1
fi
log "INFO" "start syncing files of master file: $file"
local file_pdf="${file/.sgml/.pdf}"
local file_html="${file/.sgml/.html}"
local dir_html="${file/.sgml}"
local file_base="`basename "${file/.sgml}"`"
local file_dest_pdf="$DIR_DEST_BASE/${file_base}.pdf"
local file_dest_html="$DIR_DEST_BASE/${file_base}.html"
local dir_dest_html="$DIR_DEST_BASE/$file_base"
local file_dest_status="$DIR_DEST_BASE/${file_base}.last"
log "INFO" "copy PDF file: $file_pdf"
cp -p "$file_pdf" "$file_dest_pdf"
if [ $? -ne 0 ]; then
log "ERROR" "can't copy PDF file: $file_pdf"
return 1
fi
if [ ! -f "$file_dest_pdf" ]; then
log "ERROR" "destination PDF file is not a file or doesn't exist: $file_dest_pdf"
return 1
fi
chmod 644 "$file_dest_pdf"
if [ $? -ne 0 ]; then
log "ERROR" "can't adjust permissions of PDF file: $file_dest_pdf"
return 1
fi
log "INFO" "copy HTML file: $file_html"
cp -p "$file_html" "$file_dest_html"
if [ $? -ne 0 ]; then
log "ERROR" "can't copy HTML file: $file_html"
return 1
fi
if [ ! -f "$file_dest_html" ]; then
log "ERROR" "destination HTML file is not a file or doesn't exist: $file_dest_html"
return 1
fi
chmod 644 "$file_dest_html"
if [ $? -ne 0 ]; then
log "ERROR" "can't adjust permissions of HTML file: $file_dest_html"
return 1
fi
if [ ! -d "$dir_html" ]; then
log "ERROR" "source directory for HTML doesn't exist: $dir_html"
return 1
fi
if [ ! -d "$dir_dest_html" ]; then
log "ERROR" "destination directory for HTML doesn't exist: $dir_dest_html"
return 1
fi
if [ ! -w "$dir_dest_html" ]; then
log "ERROR" "destination directory for HTML isn't writable: $dir_dest_html"
return 1
fi
log "INFO" "copy HTML directory: $dir_html -> $dir_dest_html"
rsync --delete -r "$dir_html/" "$dir_dest_html/"
if [ $? -ne 0 ]; then
log "ERROR" "can't sync HTML dir: $dir_html"
return 1
fi
log "INFO" "update status file: $file_dest_status"
touch "$file_dest_status"
if [ $? -ne 0 ]; then
log "ERROR" "can't update status file: $file_dest_status"
return 1
fi
}
## main
main() {
for file in $*; do
download "$URL_BASE" "$file"
if [ $? -ne 0 ]; then
continue
fi
dir="$DIR_BASE/${file/.sgml}"
check "$DIR_DOWNLOAD/$file" "$DIR_BASE/$file" "$dir"
if [ $? -eq 0 ]; then
process "$DIR_BASE/$file"
fi
copy "$DIR_BASE/$file"
done
}
# parse options
while getopts "dg" opt; do
case $opt in
d)
force_download=1
;;
g)
force_download=1
force_generate=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
shift $((OPTIND-1))
case $1 in
'de')
files="$FILE_DE"
;;
'en')
files="$FILE_EN"
;;
'fr')
files="$FILE_FR"
;;
'pt')
files="$FILE_PT_BR"
;;
'all')
files="$FILE_EN $FILE_DE $FILE_FR $FILE_PT_BR"
;;
esac
main $files

View File

@ -1,47 +0,0 @@
#!/bin/sh
#
# $Id$
#
# Small helper script to fix broken SGML code
#
# (P) & (C) by Peter Bieringer <pb at bieringer dot de>
#
# 20020119/PB: initial
if [ -z "$1" ]; then
FILE_SGML="Linux+IPv6-HOWTO.sgml"
else
FILE_SGML="$1"
fi
FILE_LYX="`basename $FILE_SGML .sgml`.lyx"
FILE_TMP="tmp.sgml"
PROG_FIX_TABLETAG="sgmllyxtabletagfix.pl"
PROG_FIX_QUOTE="sgmllyxquotefix.pl"
if [ "$FILE_LYX" -nt "$FILE_SGML" ]; then
echo "ERR : LyX file '$FILE_LYX' is newer than SGML file '$FILE_SGML' - forgot to export?"
exit 1
fi
if [ -f "$FILE_TMP" ]; then
echo "INF : Temporary file exists, remove it!"
rm "$FILE_TMP"
fi
if [ -f "$FILE_TMP" ]; then
echo "ERR : Ooops, temporary file still exists!"
exit 1
fi
echo "INF : Fix SGML now"
cat "$FILE_SGML" | ./$PROG_FIX_TABLETAG | ./$PROG_FIX_QUOTE >$FILE_TMP
echo "INF : Remove old SGML file '$FILE_SGML'"
rm "$FILE_SGML"
echo "INF : Rename temporary file to '$FILE_SGML'"
mv "$FILE_TMP" "$FILE_SGML"

View File

@ -1,48 +0,0 @@
#!/usr/bin/perl
#
# $Id$
#
# SGML LyX qoute entinity fix tool
#
# (P) & (C) 2002 by Peter Bieringer <pb@bieringer.de>
#
# Published under the GNU GPL licence
#
# Takes SGML output exported by LyX and fix a bug regarding quote entinities
# Don't know the reason what causes this, but it is wrong.
#
# Replaces:
# &ldquo; -> &quot;
# &rdquo; -> &quot;
#
# Changes:
# 20020125: Initial release
# 20020713: spelling fix
#
# Known bugs:
# Entity must be in one line
print STDERR "INF : Replacing special quotes entities\n";
while (<STDIN>) {
my $line = $_;
chomp $line;
#print "$line";
#print "\n";
if ($line =~ /&ldquo;/) {
print STDERR "<";
# Substitute
$line =~ s/&ldquo;/&quot;/g;
};
if ($line =~ /&rdquo;/) {
print STDERR ">";
# Substitute
$line =~ s/&rdquo;/&quot;/g;
};
print $line . "\n";
};
print STDERR "finished\n";

View File

@ -1,45 +0,0 @@
#!/usr/bin/perl
#
# $Id$
#
# SGML LyX table tag fix tool
#
# (P) & (C) 2002 by Peter Bieringer <pb@bieringer.de>
#
# Published under the GNU GPL licence
#
# Takes SGML output exported by LyX and fix a bug in the table tag.
# Don't know the reason what causes this, but it is wrong.
# -> This bug is fixed in LyX 1.1.6fix4
#
# Example:
# - <colspec colname="col0" align="center"/>
# + <colspec colname="col0" align="center">
#
# Changes:
# 20020119/PB: Initial release
# 20020125/PB: Minor review
# 20020130/PB: add comment
#
print STDERR "INF : Fix 'colspec' lines\n";
while (<STDIN>) {
my $line = $_;
chomp $line;
#print "$line";
#print "\n";
if ($line =~ /^<colspec/) {
if ($line =~ /\/>$/) {
print STDERR "C";
# Substitute '/>' with '>'
$line =~ s/\/>$/>/g;
};
};
print $line . "\n";
};
print STDERR "\n";