Wikipedia:WikiProject Chemistry/Structure drawing workgroup/Mysid's script: Difference between revisions

Content deleted Content added
m a little something so the syntax hilighting doesn't go mad
Upload my latest version: Support for superscripts as well.
Line 42:
#runs faster:
#Match "x1=" and "y1=", but don't match on x radius and y radius.
while(/[^r]([xy])[12]{0,1}=\"(\d+)/g) {
if($1 eq "y"){
$maxy = $2 if($2>$maxy);
Line 71:
if(/<svg .*viewBox="0 0 (\d+) (\d+)"/) {
$_ = "<svg width=\"".$1."px\" height=\"".$2."px\" version=\"1.0\" viewBox=\"0 0 $1 $2\" xmlns=\"http://www.w3.org/2000/svg\">\n";
}
# Replace baseline-shift="super" with a numeric baseline-shift
if (/y="([\d\.]+)">.*<tspan baseline-shift="super"/) {
$vy = $1;
$oy = $1-4;
s/baseline-shift="super"/y="$oy"/g;
s/<\/tspan>([^<]+)</<\/tspan><tspan y="$vy">$1<\/tspan></g;
}
# Replace baseline-shift="sub" with a numeric baseline-shift