| Ilya Zakharevich on Wed, 28 Feb 2001 20:50:26 -0500 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| [PATCH] Better PODs |
I think this patch fixes 95% of remaining problems with quasi-parsing
of TeX in PARI docs. It also supports a new kind of output: "dumb
POD". [It looks like the "standard" pod2whatever converters are too
dumb to support feature-rich POD.]
I also added new make targets, .html files. I tried `make
tutorial.html', and it is almost usable - though I used pretty old pod2html.
Enjoy,
Ilya
P.S. I found two errors in TeX: Docs for subst include \smallskip in
a verbatim section, and "Integration the hard way" includes \cbr
in what I think is not an appropriate place.
--- ./doc/gphelp.in Fri Feb 2 14:45:58 2001
+++ ./doc/gphelp.in-new Sun Feb 11 03:37:38 2001
@@ -35,6 +35,8 @@
#
# -to_pod file convert file to POD (should be the only args)
#
+# -to_dumbpod file same, but without nested formating
+#
# Granted environment variables (override):
# GPTMPDIR: where temporary files will go (/tmp by default).
# GPDOCDIR: where is manual (by default, where make install will put it).
@@ -56,7 +58,9 @@ $gzip = "gzip";
$zcat = "$gzip -dc";
$refcard = (@ARGV and $ARGV[-1] =~ /refcard/i);
-&to_pod() if @ARGV == 2 && $ARGV[0] eq '-to_pod';
+
+$dumb_pod=1, $ARGV[0] = '-to_pod' if @ARGV && $ARGV[0] eq '-to_dumb_pod';
+&to_pod() if @ARGV == 2 && $ARGV[0] eq '-to_pod';
&options(); &init();
if ($#ARGV < 0) { &treat($_); cleanexit(); }
@@ -77,7 +81,7 @@ cleanexit();
# Procedures
#
sub cleanexit {
- print "\e[0m";
+ print "\e[0m" unless $to_pod;
exit 0;
}
@@ -555,28 +559,37 @@ sub detex
# We use the special char @ to transmit special sequences
sub inittr {
- @ou = qw( dollar nbrk startbold endbold startcode endcode
+ @ou = qw( dollar nbrk startbold endbold startcode endcode
+ obr cbr uuml ouml agrave eacute
startpodcode endpodcode startlink endlink
startbcode endbcode startbi endbi startit endit
startword endword startlword endlword pm empty gt lt podleader );
@tr{@ou} = map "\@[$_]", @ou;
$tr{dollar} = '$' if $to_pod;
-
+
%pr = ( dollar => '',
- nbrk => 'S< >',
+ ldollar => '$', # literal dollar
+ nbrk => 'S< >',
startbold => 'B<',
endbold => '>',
startcode => 'C<',
startlink => 'L<',
endlink => '>',
endcode => '>',
+ obr => '{',
+ cbr => '}',
startpodcode => 'C<',
endpodcode => '>',
- startbcode => 'B<C<',
- endbcode => '>>',
- startbi => 'B<I<',
- endbi => '>>',
+ ( $dumb_pod
+ ? (startbcode => 'B<',
+ endbcode => '>',
+ startbi => 'B<',
+ endbi => '>',)
+ : (startbcode => 'B<C<',
+ endbcode => '>>',
+ startbi => 'B<I<',
+ endbi => '>>')),
startit => 'I<',
endit => '>',
startword => 'F<',
@@ -586,23 +599,42 @@ sub inittr {
pm => 'F<+->',
"gt" => 'E<gt>',
"lt" => 'E<lt>',
+ ouml => 'E<ouml>',
+ uuml => 'E<uuml>',
+ eacute => 'E<eacute>',
+ agrave => 'E<agrave>',
empty => 'Z<>',
podleader => '=',
);
}
+sub indent_equally { my $in = shift; $in =~ s/^[ \t]*/ /mg; $in}
+
sub basic_subst
{
local($_) = shift;
- s/([^\\])\\\{/$1`lBrAcE'/g;
- s/([^\\])\\\}/$1`rBrAcE'/g;
- s/\A\\q?quad\s+/$tr{nbrk}$tr{nbrk}/;
+ s/(\S)[ \t]*\n[ \t]+/$1\n/gm;
+ s/([^\\])\\\{/$1$tr{obr}/g;
+ s/([^\\])\\\}/$1$tr{cbr}/g;
+ s/([^\\])\\-/$1/g;
+ s/\A\\q?quad(?![a-zA-Z])\s*/$tr{nbrk}$tr{nbrk}/;
s|\\wwwsite|$wwwsite|g;
s|\\miscdir|$miscdir|g;
s/^\\def\\.*\{\n.*\n\}//gm;
s/\\def\\.*//g;
+ s(\\footnote\s*\{?\*+\}?\s*\{\s*((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\})
+ {$tr{startbold}FOOTNOTE$tr{endbold}$tr{lt}$tr{lt}$tr{lt} $1 $tr{gt}$tr{gt}$tr{gt}}g;
s/(\{[\w\s]+)\{\}([\s\w]+\})/$1$2/g; # {nf{}init}
+ s(\\op(?![a-zA-Z])\s*)({\\it op\\/})g; # {nf{}init}
+ s/\\(leavevmode|strut)(?![a-zA-Z])\s*//g;
+ s/ \\funno \s*
+ { \s* ((?:[^{}]|\{[^{}]*\})*) } \s*
+ { \s* ((?:[^{}]|\{[^{}]*\})*) } \s*
+ { \s* ((?:[^{}]|\{[^{}]*\})*) }
+ /\\noindent{\\tt $1 \$\\key{$2}\$($3)}/gx;
+ s/\\funs\s*\{((?:[^{}]|\{[^{}]*\})*)\}\s*\{((?:[^{}]|\{[^{}]*\})*)\}/\\fun{}{$1}{$2}/g;
+ s/\\fun\s*\{([^{}]*)\}\s*\{((?:[^{}]|\{[^{}]*\})*)\}\s*\{((?:[^{}]|\{[^{}]*\})*)\}/\\kbd{$1 \\key{$2}($3)}\\sidx{$2}/g;
s/\\\\(?=[a-zA-Z])/\\bs /g;
s/\\b{}\\b{}/\\bs\\bs /g;
@@ -617,8 +649,18 @@ sub basic_subst
s/\\(~|tilde)/~/g;
s/\\(equiv)(?![a-zA-Z])/ = /g;
+ s/\\`a/$tr{agrave}/;
+ s/\\`{a}/$tr{agrave}/;
+ s/\\"o/$tr{ouml}/;
+ s/\\"{o}/$tr{ouml}/;
+ s/\\"u/$tr{uuml}/;
+ s/\\"{u}/$tr{uuml}/;
+ s/\\'e/$tr{eacute}/;
+ s/\\'{e}/$tr{eacute}/;
s/(^|[^\\])%.*/$1/g; # comments
+ s/\\vadjust\s*\{\s*\\penalty\s*\d+\s*\}//g;
+
# We do not strip %\n, thus:
s/\\kbd{\n\s*/\\kbd{/g;
s/\$\\bf(\b|(?=[\d_]))\s*([^\$]+)\$/\$$tr{startbcode}$1$tr{endbcode}\$/g;
@@ -631,6 +673,9 @@ sub basic_subst
s/\\TeX(\W)/TeX$1/g;
s/ *\\circ\b */ o /g;
s/\\d?frac{\s*((?:[^{}]|\{[^{}]*\})*)}{\s*((?:[^{}]|\{[^{}]*\})*)}/($1)\/($2)/g;
+ s(\\d?frac\s*(\d)\s*(\d))(($1/$2))g;
+ s[{\s*(\w)\s*\\over(?![a-zA-Z])\s*(\w)\s*}]{($1/$2)}g;
+ s[{\s*((?:[^{}]|\{[^{}]*\})*)\\over(?![a-zA-Z])\s*((?:[^{}]|\{[^{}]*\})*)}][($1)/($2)]g;
# \def\synt#1#2{\syn{#1}{\tt #2}}
# \def\syn#1#2{\synx{#1}{#2}{#1}}
@@ -642,7 +687,6 @@ sub basic_subst
# May be used with an empty arg
s/\\typ\{([^\}]*)\}/$tr{startcode}t_$1$tr{endcode}/g;
- s/\{ *\}//g; # empty args
s/(\\string)?\\_/_/g;
s/\\([#\$&%|])/$1/g;
s/\\(hat(?![a-zA-Z])|\^)({\\?\s*})?/^/g;
@@ -651,12 +695,12 @@ sub basic_subst
s/\\neq?(?![a-zA-Z])/ != /g;
s/\\enspace(?![a-zA-Z])/ /g;
s/\\times(?![a-zA-Z]) */ x /g;
- s/\\infty(?![a-zA-Z]) */oo /g;
+ s/\\infty(?![a-zA-Z]) */ oo /g;
s/ *\\(bmod|mod) */ mod /g;
s/ *\\pmod(?![a-zA-Z]) *\{\s*((?:[^{}]|\{[^{}]*\})*)\}/ (mod $1)/g;
s/ *\\cdot(?![a-zA-Z]) */./g; # Maybe " . "?
s/ *(\\|\@)[lc]?dots(?![a-zA-Z]) */.../g;
- s/\\(log|sin|cos|lim|tan|mod|sqrt|exp|ln|det|Re|Im|deg|wp)(?![a-zA-Z])/$tr{startlword}$1$tr{endlword}/g;
+ s/\\(log|sin|cos|lim(proj)?|tan|mod|sqrt|exp|ln|det|Re|Im|deg|wp|cap|oplus)(?![a-zA-Z])/$tr{startlword}$1$tr{endlword}/g;
s/\\pi(?![a-zA-Z])/$tr{startword}Pi$tr{endword}/g;
s/\\(Alpha | Beta | Chi | Delta | Epsilon | Phi | Gamma
| Eta | Iota | vartheta | Kappa | Lambda | Mu | Nu | Omicron
@@ -675,39 +719,42 @@ sub basic_subst
s/\\ref\{[^\}]*\}/$tr{startbold}??$tr{endbold}/g unless $to_pod;
s/\\secref\{[^\}]*\}/Section ($tr{startbold}??$tr{endbold})/g unless $to_pod;
s/\\label\{[^\}]*\}//g unless $to_pod;
- s/\\rightarrow(?![a-zA-Z])/C<--E<gt>>/g;
- s/\\longleftrightarrow(?![a-zA-Z])/C<E<lt>-----E<gt>>/g;
s/\\(noindent|medskip|bigskip|smallskip|left|right)(?![a-zA-Z])[ \t]*//g;
- s/\\vfill *\\eject//g;
- s/\\(q|quad)(?![a-zA-Z])/ /g;
- s/\\qquad(?![a-zA-Z])/ /g;
- s/\\centerline\s*\{\s*(?:\\tt\b\s*)?(.*(\n[ \t].*)*)\}(?=\s*$)/ $1/g;
- s/\\centerline\s*\{\s*(?:\\tt\b\s*)?((?:[^{}]|\{[^{}]*\})*)\}/ $1/g;
+ s/\\vfill *(\\eject)?//g;
+ s/\\(q|quad)(?![a-zA-Z])\s*/ /g;
+ s/\\qquad(?![a-zA-Z])\s*/ /g;
+
+ s/\\centerline\s*\{\s*(?:\\tt\b\s*)?(.*(\n[ \t].*)*)\}(?=\s*$)/indent_equally($1)/ge;
+ s/\\centerline\s*\{\s*(?:\\tt\b\s*)?((?:[^{}]|\{[^{}]*\})*)\}/ indent_equally($1)/ge;
+
s/\\big\b//g;
- s/\\settabs.*//;
+ s/\\settabs.*//;
s/^\\\+/$tr{nbrk}/gm;
s/\\\+//g;
s/\\cr(?![a-zA-Z])//g;
s/\\B(?![a-zA-Z])/\\kbd{BIL}/g;
- s/\\funs\s*\{((?:[^{}]|\{[^{}]*\})*)\}\s*\{((?:[^{}]|\{[^{}]*\})*)\}/\\fun{}{$1}{$2}\\sidx{$2}/g;
- s/\\fun\s*\{([^{}]*)\}\s*\{((?:[^{}]|\{[^{}]*\})*)\}\s*\{((?:[^{}]|\{[^{}]*\})*)\}/\\kbd{$1 \\key{$2}($3)}\\sidx{$2}/g;
- s/ *\\leq?(?![a-zA-Z]) *([^ ])/<=$1/g;
- s/ *\\geq?(?![a-zA-Z]) *([^ ])/>=$1/g;
s/ *([=><]) */ $1 /g;
s/ *< *([=<]) */ <$1 /g;
s/ *> *([=>]) */ >$1 /g;
s/ *([*+-\/^&=|:]) += */ $1= /g;
- s/ *\\Rightarrow */ ==> /g;
+ s/ *\\Rightarrow */ ==$tr{gt} /g;
+ s/\\rangle(?![a-zA-Z])\s*/$tr{startcode}$tr{gt}$tr{endcode}/g;
+ s/\\langle(?![a-zA-Z])\s*/$tr{startcode}$tr{lt}$tr{endcode}/g;
+ s/\\rightarrow(?![a-zA-Z])\s*/$tr{startcode}--$tr{gt}$tr{endcode}/g;
+ s/\\longleftrightarrow(?![a-zA-Z])\s*/$tr{startcode}$tr{lt}-----$tr{gt}$tr{endcode}/g;
+ s/\\mapsto(?![a-zA-Z])\s*/$tr{startcode}|---$tr{gt}$tr{endcode}/g;
+ s/ *\\geq?(?![a-zA-Z]) *([^ ])/ $tr{startcode}$tr{gt}=$tr{endcode} $1/g;
+ s/ *\\leq?(?![a-zA-Z]) *([^ ])/ $tr{startcode}$tr{lt}=$tr{endcode} $1/g;
s/\\(vers|PARIversion)(?![a-zA-Z])/$tr{startbold}$version$tr{endbold}/;
s/\\([QRCFZNapdf])(?![a-zA-Z])/$tr{startbi}$1$tr{endbi}$2/g;
s/\\([QRCFZN])\1(?![a-zA-Z])/$tr{startbi}$1$tr{endbi}$2/g;
s/\\Bbb\b\s*(\w)/$tr{startbi}$1$tr{endbi}/g;
- s/\\obr/{/g; s/\\cbr/}/g;
+ s/\\([oc]br)/$tr{$1}/g;
s/\\quo(?![a-zA-Z])/\"/g;
s/(^|\s)\{(\w+)\}/$1$2/g;
@@ -719,16 +766,16 @@ sub basic_subst
s/\\teb\{([^\}]*)\}/\\sidx{$1}$tr{startbold}$1$tr{endbold}/g;
s/\\tet\{([^\}]*)\}/\\sidx{$1}$tr{startcode}$1$tr{endcode}/g;
s/\\tev\{([^\}]*)\}/\\sidx{$1}$tr{startit}$1$tr{endit}/g;
- s/\\kbd\{((?:[^{}]|\{[^{}]*\})*)\}/$tr{startcode}$1$tr{endcode}/g;
+ s/\\\$/$tr{ldollar}/g;
+ s/\\kbd\s*\{\s*</\\kbd{$tr{lt}/g if $to_pod;
+ s/\\kbd\s*\{\s*>/\\kbd{$tr{gt}/g if $to_pod;
+ s/\\kbd\s*\{((?:[^{}]|\{[^{}]*\})*)\}/$tr{startcode}$1$tr{endcode}/g;
- s/\\key\{([^\}]*)\}/$tr{startbold}$1$tr{endbold}/g unless $refcard;
+ s/\\key\{((?:[^{}]|\{[^{}]*\})*)\}/$tr{startbold}$1$tr{endbold}/g unless $refcard;
-# s/\\(?:key|li)\s*{(.*)}\s*{(.+)}[ \t]*\n/\n\n=item C<$2>\n\n$1\n\n/msg;
-# s/\\(?:key|li)\s*{(.*)}\s*{}[ \t]*\n/\n\n=back\n\n$1\n\n=over\n\n/mgs;
-# s/\\(key|var)(?![a-zA-Z])\s*{(\w+)}/C<$2>/mg;
if ($refcard) {
- s/\\(?:key|li)\{((?:[^{}]+(?=[{}])|\{[^{}]+\})*)\}\s*\{\}[ \t]*\n/\n\n=back\n\n$1\n\n=over\n\n/g if $refcard;
- s/\\(?:key|li)\{((?:[^{}]+(?=[{}])|\{[^{}]+\})*)\}\s*\{(([^{}]+(?=[{}])|\{[^{}]+\})*)\}/\n=item C<$2>\n\n$1\n/g if $refcard;
+ s/\\(?:key|li)\{((?:[^{}]+(?=[{}])|\{[^{}]*\})*)\}\s*\{\}[ \t]*\n/\n\n=back\n\n$1\n\n=over\n\n/g;
+ s/\\(?:key|li)\{((?:[^{}]+(?=[{}])|\{[^{}]*\})*)\}\s*\{(([^{}]+(?=[{}])|\{[^{}]*\})*)\}/\n=item $tr{startcode}$2$tr{endcode}\n\n$1\n/g;
}
s/\\var\{([^\}]*)\}/$tr{startit}$1$tr{endit}/g;
@@ -737,11 +784,12 @@ sub basic_subst
s/\\kbdsidx/\\sidx/g;
s/\\sidx\{[^\}]*\}//g unless $to_pod;
s/\\[a-zA-Z]*idx\{([^\}]*)\}/$1/g unless $to_pod;
- s/\\(?:text|hbox)\s*\{ *(?:\\it\b\s*)?(([^{}]+(?=[{}])|\{[^{}]+\})*)\}/$1/g;
+ s/\\(?:text|hbox)\s*\{ *(?:\\it\b\s*)?(([^{}]+(?=[{}])|\{[^{}]*\})*)\}/$1/g;
s/\\(text|hbox)//g;
- s/\{ *\\(it|sl) *(([^{}]+(?=[{}])|\{[^{}]+\})*)\}/$tr{startit}$2$tr{endit}/g;
- s/\{ *\\bf *(([^{}]+(?=[{}])|\{[^{}]+\})*)\}/$tr{startbold}$1$tr{endbold}/g;
- s/\{ *\\tt *(([^{}]+(?=[{}])|\{[^{}]+\})*)\}/$tr{startpodcode}$1$tr{endpodcode}/g;
+ s/^([ \t]+)\{ *\\(it|sl|bf|tt)\b/S<$1>{\\$2/gm;
+ s/\{ *\\(it|sl) *(([^{}]+(?=[{}])|\{[^{}]*\})*)\}/$tr{startit}$2$tr{endit}/g;
+ s/\{ *\\bf *(([^{}]+(?=[{}])|\{[^{}]*\})*)\}/$tr{startbold}$1$tr{endbold}/g;
+ s/\{ *\\tt *(([^{}]+(?=[{}])|\{[^{}]*\})*)\}/$tr{startpodcode}$1$tr{endpodcode}/g;
$seek=1 if (s/\{ *\\it */$tr{startit}/g);
if ($seek) { $seek=0 if (s/\}/$tr{endit}/) }
s/\\(backslash|bs)\{(\w)\}/\\$2/g;
@@ -750,16 +798,15 @@ sub basic_subst
s/\@com(.*)$/$tr{startcode}$1$tr{endcode}/g;
# Last resort:
- s/\\kbd\{(.*?)\}/$tr{startcode}$1$tr{endcode}/g;
+ s/\\kbd\s*\{(.*?)\}/$tr{startcode}$1$tr{endcode}/g;
s/^([ \t]{3,})\Q$tr{startcode}\E(.*)\Q$tr{endcode}\E/$1$2/gmo if $to_pod;
# Last resort:
s/^([ \t]{3,})\Q$tr{startcode}\E(.*?)\Q$tr{endcode}\E/$1$2/gmso if $to_pod;
# Remove leading spaces unless have embedded wrapped code:
s/^[ \t]+//gm if $to_pod and /^\S/ and not /^[ \t]*\n[ \t]/m;
- s/`lBrAcE'/\\{/g;
- s/`rBrAcE'/\\}/g;
+ s/\{ *\}//g; # empty args
- s{\Q$tr{startcode}\E(?=(ftp|http)://)}{$tr{startlink}}go if $to_pod;
+ s{\Q$tr{startcode}\E((ftp|http)://.*?)\Q$tr{endcode}\E}{$tr{startlink}$1$tr{endlink}}go if $to_pod;
$_;
}
@@ -788,14 +835,22 @@ sub code_subst {
my $in = shift;
$in =~ s/\@dots\b/.../g;
$in =~ s/\@miscdir\b/$miscdir/g;
- if ($in =~ /\@com/)
+ if ($in =~ /\@com(.*)/)
{
- $in = $` . $tr{endcode} . &basic_subst($') . $tr{startcode};
+ if ($to_pod) {
+ $in = $` . &basic_subst($1) . code_subst($');
+ } else {
+ $in = $` . $tr{endcode} . &basic_subst($1) . $tr{startcode} . code_subst($');
+ }
}
if ($in =~ /\@Ccom(.*)\*\//)
{
- $in = $` . $tr{endcode} . &basic_subst($1) . $tr{startcode}
- . "*/" . &code_subst($');
+ if ($to_pod) {
+ $in = $` . &basic_subst($1) . "*/" . &code_subst($');
+ } else {
+ $in = $` . $tr{endcode} . &basic_subst($1) . $tr{startcode}
+ . "*/" . &code_subst($');
+ }
}
$in;
}
@@ -803,14 +858,10 @@ sub code_subst {
sub wrap_code {
my $in = shift;
$in =~ s/^[ \t]+$//mg;
-# if ($in =~ /[A-Z]</ && 0) { # No such things so early
-# $in =~ s/^(.)/\nS< >$1/mg;
-# } else {
- $in = &code_subst($in);
- $in =~ s/^(.)/ $1/mg;
-# }
+ $in = &code_subst($in);
+ $in =~ s/^(.)/ $1/mg;
$in =~ s/\s*\Z//;
- $in =~ s/\\kbd\{((?:[^{}]|\{[^{}]*\})*)\}/$1/g if $to_pod;
+# $in =~ s/\\kbd\{((?:[^{}]|\{[^{}]*\})*)\}/$1/g if $to_pod;
$in =~ s/\$([^\$\n]*)\$/$1/g if $to_pod;
"\n\n$in\n\n";
}
@@ -828,15 +879,17 @@ sub for_index {
$in;
}
+sub strip_trail { my $in = shift; $in =~ s/\s+\Z//; $in }
+
+# This subroutine works in paragraph mode
sub TeXprint_topod {
s/\A\s+//;
s/^\\def\\.*\{\n.*\n\}//gm;
s/\\def\\.*//g; # Repeated in basic_subst, as the next one
s/(\{[\w\s]+)\{\}([\s\w]+\})/$1$2/g; # {rnf{}llgram}
- # \def\sectype#1#2{\subsec{Type \typ{#1} (#2s):}\sidx{#2}}
- # \def\sectypeindex#1#2#3{\subsec{Type \typ{#1} (#2):}\sidx{#3}}
- # \def\sectypes#1#2#3{\subsec{Types \typ{#1} and \typ{#2} (#3s):}\sidx{#3}}
+ s/\\vbox\s*\{\s*\\bprog/\\bprog/g;
+ s/([\\\@])eprog\s*\}/$1eprog/g;
# \n is below to prevent splitting on ' '
# We also remove ':'
@@ -850,9 +903,9 @@ sub TeXprint_topod {
s/(\\(?:section|subsec(?:ref|idx|op)?)\s*{(?:(?:[^{}]+(?=[{}])|{[^{}]+})+)})\.?\s*\\(label|sidx)/$1\n\\$2/;
# last if /\\subsec[\\{}ref]*[\\\${]$help[}\\\$]/o;
- s/\\chapter\s*{((?:[^{}]|\{[^{}]*\})*)}/\n\n$tr{podleader}head1 NAME\n\nlibPARI - $1\n\n$tr{podleader}head1 DESCRIPTION\n\n/;
- s/\\appendix\s*{((?:[^{}]|\{[^{}]*\})*)}/\n\n$tr{podleader}head1 NAME\n\nAppendix - $1\n\n$tr{podleader}head1 DESCRIPTION\n\n/;
- s/\\section\s*{((?:[^{}]|\{[^{}]*\})*)}/"\n\n$tr{podleader}head1 " . indexify($1) . "\n\n"/e;
+ s/\\chapter\s*{((?:[^{}]|\{[^{}]*\})*)}\s*/\n\n$tr{podleader}head1 NAME\n\nlibPARI - $1\n\n$tr{podleader}head1 DESCRIPTION\n\n/;
+ s/\\appendix\s*{((?:[^{}]|\{[^{}]*\})*)}\s*/\n\n$tr{podleader}head1 NAME\n\nAppendix - $1\n\n$tr{podleader}head1 DESCRIPTION\n\n/;
+ s/\\section\s*{((?:[^{}]|\{[^{}]*\})*)}\s*/"\n\n$tr{podleader}head1 " . indexify($1) . "\n\n"/e;
# Try to delimit by :
s/\\subsec(?:ref|idx|op)?(?:unix)?\s*{(([^{}]+(?=[{}])|{[^{}]+})+)}((\W*default:)?[^\n:]*):\s*/"\n\n$tr{podleader}head2 " . indexify("$1$3") . "\n\n"/e;
@@ -870,24 +923,37 @@ sub TeXprint_topod {
/\Q$tr{podleader}\Ehead1|\\title(?![a-zA-Z])\s*\{/o and $seen_start = 1
or $seen_start or return; # Skip now!
- s/\\title\s*\{([^{}\s]*)(\s+([^{}]*))?\}(\s*\\centerline\s*\{([^{}]*)\})?/$tr{podleader}head1 NAME\n\n$1 - $3. $5\n\n/ and $seen_title++
+ s/\\title\s*\{([^{}\s]*)(\s+([^{}]*))?\}(\s*\\centerline\s*\{([^{}]*)\})?\s*/$tr{podleader}head1 NAME\n\n$1 - $3. $5\n\n/ and $seen_title++
unless $seen_title;
- s/\\title\s*\{([^{}\s]*)(\s+([^{}]*))?\}(\s*\\centerline\s*\{([^{}]*)\})?/\n\n/;
+ s/\\title\s*\{([^{}\s]*)(\s+([^{}]*))?\}(\s*\\centerline\s*\{([^{}]*)\})?\s*/\n\n/;
s/\\parskip.*/\n/g; # Up to end of the line
#s/([A-Z])\</$1 < /g; # Disambiguate with POD...
- s/\\((small|big)skip|newcolumn|noindent|(short)?copyrightnotice|hfill|break|par|leavevmode|strut|endgroup|bye)(?![a-zA-Z])[ \t]*/\n\n/g;
- s/^[ \t]*\\hskip\s*\w+//gm;
+
+ # Duplicate removal of settabs, since they may contain \hskip
+ s/\\settabs.*//;
+ s/^[ \t]*\\hskip\s*\w+/$tr{nbrk}/g;
+ s/[ \t]*\\hskip\s*\w+/\n$tr{nbrk}/g;
+ 1 while s/ \\
+ ( (small|big)skip | newcolumn | noindent
+ | (short)?copyrightnotice | hfill | break | par
+ | leavevmode | strut | endgroup | bye
+ )
+ (?![a-zA-Z])[ \t]*(\n\s*)
+ /\n\n/gx;
s/'(\W)'/{\\tt '$1'}/g;
s/(\\\w+)(\\hbox)/$1 $2/g;
s/\\hbox\s*\{(?:\\it\b\s*)?((?:\\[\{\}]|[^{}]|\{[^{}]*\})*)\}/$1/g;
# substitute non-verbatim code
- if (/\\bprog/)
- {
- s/\s*\\bprog(?:tabs[^\n]*)?(?![a-zA-Z])\s*(.*?)(\\|@)eprog\s*/wrap_code($1)/ges;
+ $acc = '';
+ pos = 0;
+ while ( s/\A(.*?)\\bprog//s ) {
+ $acc .= basic_subst(strip_trail($1));
+ $_ .= <DOC> until /(\\|@)eprog\b/ or eof(DOC);
+ $acc .= wrap_code($1) if s/\A(?:tabs[^\n]*)?(?![a-zA-Z])[ \t]*\n?(.*?)(\\|@)eprog\s*//s;
}
- else { $_ = &basic_subst($_); }
+ $_ = $acc . basic_subst($_);
# s/\\kbd\{/\{\\tt /g; # startcode
# s/\\typ\{/\{\\tt t_/g; # startcode
@@ -898,13 +964,13 @@ sub TeXprint_topod {
@lines = split /^$/m, $_;
for (@lines) {
- s/>/\@[gt]/g unless /^\s/;
- s/</\@[lt]/g unless /^\s/;
+ s/>/\@[gt]/g unless /^\n*[ \t]/;
+ s/</\@[lt]/g unless /^\n*[ \t]/;
}
$_ = join '', @lines;
- s/\$\$(.*?)\$\$[ \t]*/\n\nS< >C<$1>\n\n/gs;
- s/\$([^\$]+)\$/C<$1>/g;
+ s/\$\$(.*?)\$\$\s*/\n\nS< >$tr{startcode}$1$tr{endcode}\n\n/gs;
+ s/\$([^\$]+)\$/$tr{startcode}$1$tr{endcode}/g;
s/\\s(?:ref|idx){\s*([^{}]*)}/"X<" . for_index($1) . ">"/ge; #
s/\\(?:ref|idx){\s*([^{}]*)}/"X<" . for_index($1) . ">$1"/ge;
@@ -913,30 +979,59 @@ sub TeXprint_topod {
# s/\\(?:key|li)\s*{(.*)}\s*{(.+)}[ \t]*\n/\n\n=item C<$2>\n\n$1\n\n/msg;
# s/\\(?:key|li)\s*{(.*)}\s*{}[ \t]*\n/\n\n=back\n\n$1\n\n=over\n\n/mgs;
# s/\\(key|var)(?![a-zA-Z])\s*{(\w+)}/C<$2>/mg;
- s/\\var\s*{X<(\w+)>(\w+)}/X<$1>C<$2>/mg;
- s/\\var\s*{f{}lag}/C<flag>/mg;
+ s/\\var\s*{X<(\w+)>(\w+)}/X<$1>$tr{startcode}$2$tr{endcode}/mg;
+ s/\\var\s*{f{}lag}/$tr{startcode}flag$tr{endcode}/mg;
s/\\metax(?![a-zA-Z])\s*{(.*)}\s*{\s*(\w+)(?=C\<)(.*)}[ \t]*\n/\n\n=item C<L<$2>$3>\n\n$1\n\n/mg;
s/\\metax(?![a-zA-Z])\s*{(.*)}\s*{(.*)}[ \t]*\n/\n\n=item C<$2>\n\n$1\n\n/mg;
s/C\<\{\}=/C\<=/g;
s/\\fl(?![a-zA-Z])/I<flag>/g;
s/\\file(?![a-zA-Z])/F<file>/g;
+ s/\\(unix|emacs)\b\s*(\{?)(\s*\\(no)?indent)?\s*/X<\U$1>$2/g;
+ s/\A\\label\s*\{([\w:.-]*)\}([ \t]*\n\s*(?=[^\s=]))?/X<Label $1>/g;
s/\\label\s*\{([\w:.-]*)\}/X<Label $1>/g;
s/\\secref\s*\{([\w:.-]*)\}/L<Label $1>/g;
- s/\\begin(double)?indentedkeys/\n\n=over\n\n/g;
- s/\\end(double)?indentedkeys/\n\n=back\n\n/g;
+ s/\\begin(double)?indentedkeys\s*/\n\n=over\n\n/g;
+ s/\\end(double)?indentedkeys\s*/\n\n=back\n\n/g;
# begin/end group appear in very special context only
s/\\begingroup\W.*//s; # Eat to the end
s/\n{3,}/\n\n/g;
- s/\\subsec\{((?:[^{}]|\{[^{}]*\})+)\}/\n\n=back\n\nB<$1>\n\n=over\n\n/g; # In refcard
+ s/\\subsec\{((?:[^{}]|\{[^{}]*\})+)\}\s*/\n\n=back\n\nB<$1>\n\n=over\n\n/g; # In refcard
# for refcard:
s/{\\rm(?![a-zA-Z])\s*([^{}]*)}/$1/g;
s/\\Z<>/\\/g; # Optimize for readability
+
+ # Now replace the POD stuff
+ # Start with cosmetic stuff:
+ $in_code = 0;
+ s/(\@\[((start)|end)code\])/ ($3 ? $in_code++ : --$in_code) ? "" : $1 /ge;
+
+ if ($dumb_pod) {
+ my @stack;
+ s /(\@\[((start)|end)(\w+)\])/
+ if ($3) { # Start
+ push @stack, $4;
+ (@stack > 1 ? "\@[end$stack[-2]]" : '') . $1
+ } else { # end
+ pop @stack;
+ $1 . (@stack ? "\@[start$stack[-1]]" : '')
+ }
+ /ge
+ }
+ 1 while s/\@\[start(\w+)\](\s*)\@\[end\1\]/$2/g;
+
s/\@\[(\w+)\]/\@!$pr{$1}/g;
s/(\\\w+)\@!(\w)/$1 $2/g;
s/\@!//g;
s/\\([\{\}])/$1/g;
+ # Normalize the spacing
+ s/\n{3,}/\n\n/;
+ s/\A([ \t]*\n)+//;
+ # Single label is not healthy...
+ print "\n" if $last_glued and /\A=/; # POD markup needs a new paragraph
+ $last_glued = s/((\A|\n\n)(X<[^<>]+>)+)[ \t]*\n\n/$1\n/;
+
print;
}
@@ -953,6 +1048,14 @@ sub color
sub TeXprint
{
local($_) = $_[0];
+ s/\@\[obr\]/{/g;
+ s/\@\[cbr\]/}/g;
+ # This should better be put in Latin1... Or Win1251? ;-)
+ s/\@\[ouml\]/"o/g;
+ s/\@\[uuml\]/"u/g;
+ s/\@\[agrave\]/`a/g;
+ s/\@\[eacute\]/'e/g;
+ s/\@\[ldollar\]/\$/g;
s/\@\[end(bold|code|bcode|bi|it)\]/\e[m$ch/g;
s/\@\[start(bold|code|bcode|bi)\]/$cb\e[1m/g;
s/\@\[startit\]/$cu\e[4m/g;
--- ./config/DOC_Make.SH-pre Fri Feb 9 19:38:36 2001
+++ ./config/DOC_Make.SH Wed Feb 28 20:27:10 2001
@@ -10,7 +10,7 @@ manual: users.dvi
tutorial: tutorial.dvi
refcard: refcard.ps
-.SUFFIXES: .tex .ipf .pod .inf
+.SUFFIXES: .tex .ipf .pod .inf .dumbpod
paricfg.tex: paricfg.tex.in
sed -e 's/@version@/2.2.0/'\
@@ -93,6 +93,9 @@ veryclean: clean
.tex.pod:
perl gphelp -to_pod $*.tex > tmp_pod && mv tmp_pod $*.pod
+.tex.dumbpod:
+ perl gphelp -to_dumb_pod $*.tex > tmp_pod && mv tmp_pod $*.dumbpod
+
.ipf.inf:
ipfc /INF $*.ipf
@@ -103,3 +106,12 @@ veryclean: clean
pari.ipf: refcard.pod tutorial.pod usersch1.pod usersch1.pod usersch2.pod usersch3.pod usersch4.pod usersch5.pod appa.pod appb.pod appc.pod
pod2ipf --title="PARI/GP Manual" --by-files --section-name="Getting started" --file=refcard.pod --file=tutorial.pod --section-name="User guide" --file=usersch1.pod --file=usersch1.pod --file=usersch2.pod --file=usersch3.pod --file=usersch4.pod --file=usersch5.pod --section-name=Appendices --file=appa.pod --file=appb.pod --file=appc.pod > tmp_ipf && mv tmp_ipf pari.ipf
+
+# Wrong syntax... How to convert a group of files?
+#pari.html: refcard.dumbpod tutorial.dumbpod usersch1.dumbpod usersch1.dumbpod usersch2.dumbpod usersch3.dumbpod usersch4.dumbpod usersch5.dumbpod appa.dumbpod appb.dumbpod appc.dumbpod
+# pod2html --title="PARI/GP Manual" --by-files --section-name="Getting started" --file=refcard.dumbpod --file=tutorial.dumbpod --section-name="User guide" --file=usersch1.dumbpod --file=usersch1.dumbpod --file=usersch2.dumbpod --file=usersch3.dumbpod --file=usersch4.dumbpod --file=usersch5.dumbpod --section-name=Appendices --file=appa.dumbpod --file=appb.dumbpod --file=appc.dumbpod > tmp_ipf && mv tmp_ipf pari.html
+
+.dumbpod.html:
+ pod2html --title="PARI/GP Manual $* Getting started" --file=$*.dumbpod > tmp_html && mv tmp_html $*.html
+
+