Wikipedia:WikiProject Chemistry/Structure drawing workgroup/Mysid's script: Difference between revisions
Content deleted Content added
fix bug - matrix() calls outside of defs block were slipping through |
simplified script, removed group removal, rounding, shifted file name changes to command line |
||
Line 1:
<source lang="perl">
#!/usr/bin/perl -i.old
#Modify svg file from BKchem to work with librsvg, for use on Wikimedia.
use warnings;
use strict;
my $font_size = 24;
while (<
}▼
#Sans is the most general font definition we can use, and librsvg chokes
#on Helvetica.
s/helvetica/Sans/gi;
if(m#<text[^>]+font-size="([0-9]+)pt"#){
$font_size = $1;
▲ }
s#(font-size=")([0-9]+)%(")#$1.($2*$font_size/100)."pt".$3#ge;
# Replace baseline-shift="super" with a numeric baseline-shift
if (/y="([\d\.]+)">.*<tspan baseline-shift="super"/) {
my $vy = $1;
my $oy = $1-4;
s/baseline-shift="super"/y="$oy"/g;
s
}
# Replace baseline-shift="sub" with a numeric baseline-shift
if (/y="([\d\.]+)">.*<tspan baseline-shift="sub"/) {
my $vy = $1;
my $oy = $1+3.25;
s/baseline-shift="sub"/y="$oy"/g;
s
}
#write each line out after mangling it.
print
}
</source>
|