sub getConverter($$);
sub getNext($);
sub writeConverters($$);
+sub createConvLine($$);
sub getSubstitutes($$@)
{
my $value = $2;
my $valid = 0;
if (defined($rAllowedKeys->{$key})) {
- for my $val (@{$rAllowedKeys->{$key}}) {
- if ($val eq $value) {
+ if (ref($rAllowedKeys->{$key}) eq "ARRAY") {
+ for my $val (@{$rAllowedKeys->{$key}}) {
+ if ($val eq $value) {
+ $valid = 1;
+ last;
+ }
+ }
+ }
+ elsif ($rAllowedKeys->{$key} eq "integer") {
+ if ($value =~ /^\d+$/) {
$valid = 1;
- last;
}
}
+ elsif ($rAllowedKeys->{$key} eq "string") {
+ $valid = 1;
+ }
}
if ($valid) {
$rSubst->{$key} = [$value, 0];
chomp($l);
my ($from, $to, $cmd, $par);
($l, $from) = getNext($l);
- return undef if ($from !~ /tex$/);
+ return undef if ($from !~ /(ps|tex|dvi)$/);
($l, $to) = getNext($l);
- return undef if ($to !~ /^(dvi3?|pdf[23456]?)$/);
+ return undef if ($to !~ /^((dvi3?|pdf[23456]?)(log)?)$/);
+ my ($checkfor, $substitute, $extrapar);
+ if ($from =~ /tex/) {
+ $checkfor = qr/\s+\-shell\-(escape|restricted)/;
+ $substitute = "-shell-escape";
+ $extrapar = qr/^latex/;
+ }
+ elsif ($from =~ /ps$/) {
+ $checkfor = qr/\s+\-dALLOWPSTRANSPARENCY/;
+ $substitute = "-dALLOWPSTRANSPARENCY";
+ $extrapar = qr/hyperref-driver=dvips/;
+ }
+ else {
+ $checkfor = qr/\s+-i\s+dvipdfmx-unsafe.cfg/;
+ $substitute = "-i dvipdfmx-unsafe.cfg";
+ $extrapar = qr/^hyperref-driver=dvipdfm/;
+ }
($l, $cmd) = getNext($l);
if ($add) {
- if ($cmd !~ /\-shell-escape/) {
+ if ($cmd !~ $checkfor) {
if ($cmd =~ /^(\S+)\s*(.*)$/) {
- $cmd = "$1 -shell-escape $2";
+ $cmd = "$1 $substitute $2";
$cmd =~ s/\s+$//;
}
}
}
else {
- $cmd =~ s/\s+\-shell\-escape//;
+ $cmd =~ s/$checkfor//;
}
($l, $par) = getNext($l);
- return undef if ($par !~ /^latex/);
+ return undef if ($par !~ $extrapar);
my $key = "\"$from\" \"$to\"";
if ($add) {
return([$key, [$cmd, $par]]);
}
else {
$rConverter->{$key}->[2] = 1;
- $l = &createConvLine($key);
+ $l = &createConvLine($key, $rConverter);
}
}
+ else {
+ # Converter defined only in preferences
+ $rConverter->{$key} = $entry->[1];
+ $rConverter->{$key}->[2] = 1;
+ $l = &createConvLine($key, $rConverter);
+ }
}
}
else {