my @LocalTokens = qw (em rm bf tt sf sc sl it
rmfamily ttfamily sffamily mdseries bfseries
upshape itshape slshape scshape cal
- );
+ );
foreach (@LocalTokens) {
$MyTokens{"\\$_"} = $Text::TeX::Tokens{'\em'}
}
&ReadCommands::Merge(\%MyTokens);
# Create the fileobject
- my $file = new Text::TeX::OpenFile
+ my $file = new Text::TeX::OpenFile
$InFileName,
'defaultact' => \&clean_tex,
'tokens' => \%MyTokens;
my($eaten,$txt) = (shift,shift);
my ($outstr, $type);
- # Sub translate is given a string and one of the translation tables below.
- # It returns the translation, or just the string if there's no translation
- # Translation table for TT::Begin::Group tokens
- my %begtranstbl = (
- '$' => '\(', # LyX math mode doesn't
- '$$' => '\[', # understand \$ or $$
- );
-
- # Translation table for TT::End::Group tokens
- my %endtranstbl = (
- '$' => '\)',
- '$$' => '\]',
- );
-
# Translation table for TT::Token tokens whose translations should
# NOT have whitespace after them! See sub translate...
# Note that tokens of type TT::EndLocal are always translated to '}'. So,
# Handle the end of a local font command - insert a '}'
if (/EndLocal/) {
- # we could just say $printstr='}'
- $printstr = &translate('}', \%endtranstbl);
+ $printstr = '}';
last SWITCH;
}
-
+
# $eaten->exact_print is undefined for previous environments
$outstr = $eaten->exact_print;
if (! defined $outstr) { # comment at end of paragraph
warn "Weird undefined token $eaten!" unless $eaten->comment;
last SWITCH;
}
-
+
# Handle LaTeX tokens
if (/^Token$/) {
my $realtok = $eaten->print; # w/out whitespace
# Tokens taking arguments, like '^'
# ADD '{' if there isn't one before the argument!
+ # TODO can we check whether the command is \label, \include
+ # and not add the braces in that case?
if (/^BegArgsToken$/) {
$printstr = $outstr;
}
# End of tokens taking arguments, like '^'
- # ADD '}' if there isn't one after the last argument, i.e.,
+ # ADD '}' if there isn't one after the last argument, i.e.,
# if the previous token *wasn't* a '}'
# Kludge: for TeX style \input command ("\input foo" with no
# braces) we need to read the whole filename, but parser will have
# required arg: they'll just be copied as text
last SWITCH;
}
-
+
# Handle opening groups, like '{' and '$'.
if (/Begin::Group$/) {
- $printstr = &translate($outstr,\%begtranstbl);
+ $printstr = $outstr;
last SWITCH;
}
-
+
# Handle closing groups, like '}' and '$'.
if (/End::Group$/) {
- $printstr = &translate($outstr, \%endtranstbl);
+ $printstr = $outstr;
last SWITCH;
}
}
last SWITCH;
}
-
+
if (/End::Group::Args/) {
$printstr = $outstr;
last SWITCH;
# The default action - print the string.
$printstr = $outstr;
} # end SWITCH:for ($type)
-
+
# Actually print the string
- if (defined $printstr) {
+ if (defined $printstr) {
print OUTFILE $printstr;
$last_eaten = $eaten; #save for next time
} else {warn "Undefined printstr";}