Math-Pari
view release on metacpan or search on metacpan
libPARI/gphelp-ini view on Meta::CPAN
my($a);
$_ = $_[0];
if (/[^0-9]/ || $_ < 0 || $_ > 17)
{ print "bad color in gphelp: $_\n"; return ""; }
if ($_ < 8) { $a = $_ + 30; } else { $a = $_ + 82; }
return "\e[0;${a}m";
}
sub TeXprint {
local($_) = $_[0];
s/\@\[obr\]/{/g;
s/\@\[cbr\]/}/g;
if ($utf8)
{
s/\@\[ouml\]/ö/g;
s/\@\[uuml\]/ü/g;
s/\@\[aacute\]/á/g;
s/\@\[agrave\]/Ã /g;
s/\@\[eacute\]/é/g;
s/\@\[pm\]/±/g;
}
else
{
s/\@\[ouml\]/"o/g;
s/\@\[uuml\]/"u/g;
s/\@\[aacute\]/'a/g;
s/\@\[agrave\]/`a/g;
s/\@\[eacute\]/'e/g;
s/\@\[pm\]/+\/-/g;
}
s/\@\[label\]//g;
s/\@\[ldollar\]/\$/g;
s/\@\[end(bold|code|bcode|ref|bi|bc|bg|it)\]/$ch/g;
s/\@\[start(bold|code|bcode|ref|bi|bc|bg)\]/$cb/g;
s/\@\[startit\]/$cu/g;
s/\@\[(dollar|empty|endl?word|endpodcode|startl?word|startpodcode)\]//g;
s/\@\[lt\]/</g;
s/\@\[gt\]/>/g;
s/\\([\{\}])/$1/g;
s/\@\[nbrk\]/ /g; print "$_\n";
}
sub to_pod {
$to_pod = $ARGV[1];
inittr();
$parifile = $to_pod;
%compress = ('.gz', 'gzip -cd',
'.z', 'gzip -cd',
'.Z', 'zcat',
);
foreach $suffix (keys %compress) {
($patt = $suffix) =~ s/(\W)/\\$1/;
if ($to_pod =~ /$patt$/) { $pipe = $compress{$suffix}; last; }
}
if ($pipe) {
open(DOC,"$pipe $parifile |") ||
die "Cannot open pipe $pipe from $parifile: $!, stopped";
} else {
open(DOC,$parifile) || die "Cannot find file $parifile: $!, stopped";
}
$/=''; # Paragraph mode
while (<DOC>) {
&TeXprint_topod();
}
if ($pipe) {
close(DOC) || die "Cannot close pipe `$pipe $parifile': $!, stopped";
} else {
close(DOC) || die "Cannot close file $parifile: $!, stopped";
}
cleanexit();
}
( run in 2.014 seconds using v1.01-cache-2.11-cpan-364913b4093 )