]> git.lyx.org Git - lyx.git/blobdiff - lib/reLyX/CleanTeX.pm
clean up french language handling
[lyx.git] / lib / reLyX / CleanTeX.pm
index 307a6bb83d61032b3175c738c1f58a0d422ef4c5..92c4dfcb1918dc25d6c0ab41853cee940a97cb50 100644 (file)
@@ -55,7 +55,7 @@ sub call_parser {
     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'}
     }
@@ -63,7 +63,7 @@ sub call_parser {
     &ReadCommands::Merge(\%MyTokens);
 
 # Create the fileobject
-    my $file = new Text::TeX::OpenFile 
+    my $file = new Text::TeX::OpenFile
           $InFileName,
           'defaultact' => \&clean_tex,
           'tokens' => \%MyTokens;
@@ -81,20 +81,6 @@ sub clean_tex {
     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,
@@ -135,18 +121,17 @@ sub clean_tex {
 
           # 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
@@ -170,6 +155,8 @@ sub clean_tex {
 
           # 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;
 
@@ -206,7 +193,7 @@ sub clean_tex {
           }
 
           # 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
@@ -237,16 +224,16 @@ sub clean_tex {
               # 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;
           }
 
@@ -259,7 +246,7 @@ sub clean_tex {
               }
               last SWITCH;
           }
-          
+
           if  (/End::Group::Args/) {
               $printstr = $outstr;
               last SWITCH;
@@ -273,9 +260,9 @@ sub clean_tex {
           # 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";}