Namespaces
Variants
Actions

Eom replace for mac.pl

From Encyclopedia of Mathematics
Jump to: navigation, search
#!/usr/bin/perl -w

## This script replaces all references to
## images of tex code by strings "$_$"
## and separates reference entries by newlines

use strict;
use utf8;
use Encode;
use Unicode::Collate;

undef $/;

my $x = decode('UTF-8', readline STDIN);

$x =~ s/\n*\<table .*?\<\/table\>\n*\s*/\n\$\$•\$\$\n/sg;
$x =~ s/<img align[^>]*>/\$•\$/sg;
$x =~ s/ \[\[/\n\n\[\[/sg;
$x =~ s/\n\[\[/\[\[/sg;
$x =~ s/\n\[\[/\[\[/sg;
$x =~ s/\]\]\n/\]\]/sg;
$x =~ s/==== /====\n/sg;
$x =~ s/\.== /.==\n/sg;
$x =~ s/\$\$•\$\$\n* */\n\$\$•\$\$\n/sg;

if ($x =~ /====References====\n.*?(\<table\>.*?\<\/table\>)/) {
    my $y = $1;
    my $yy = $y;
    $yy =~ s/\n/ /sg;
    $yy =~ s/\<\/TD\>/<\/TD>\n/sg;
    $x =~ s/\Q$y\E/$yy/sg;

}

&upr($x);


sub upr{
    print encode('UTF-8', $_[0]);
}
How to Cite This Entry:
Eom replace for mac.pl. Encyclopedia of Mathematics. URL: http://encyclopediaofmath.org/index.php?title=Eom_replace_for_mac.pl&oldid=32263