]> git.lyx.org Git - features.git/commitdiff
More reLyX fun. Better support for babel.
authorJosé Matox <jamatos@lyx.org>
Thu, 18 Oct 2001 11:39:14 +0000 (11:39 +0000)
committerJosé Matox <jamatos@lyx.org>
Thu, 18 Oct 2001 11:39:14 +0000 (11:39 +0000)
Added lyx menu separator translation.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2894 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/reLyX/BasicLyX.pm
lib/reLyX/MakePreamble.pm

index 065c72105c73d2eca0a2df9259b01333b6797b9d..d976e4185d05b026b2491c852ea3b7b9b6096dd8 100644 (file)
@@ -1,3 +1,11 @@
+2001-10-18  José Abílio Oliveira Matos  <jamatos@fep.up.pt>
+
+       * reLyX/MakePreamble.pm (translate_preamble): Cleaned the code for babel.
+       Now the last language in the document option is the document language.
+       Code clean, remove unused variables.
+       
+       * reLyX/BasicLyx.pm: Added support for the lyx menu separator.
+
 2001-10-17  José Matos  <jamatos@fep.up.pt>
 
        * reLyX/MakePreamble.pm: add support for \makeindex, added support
index c33fe20446245e4adfe78042bd10269c6327a65c..521e7ee056533200e73d4efabfe366eee8ee89c6 100644 (file)
@@ -158,6 +158,7 @@ my %TextTokenTransTable = (
     '\LaTeXe' => "LaTeX2e",
     '\TeX'    => "TeX",
     '\LyX'    => "LyX",
+    '\lyxarrow' => "\\SpecialChar \\menuseparator\n",
     '\hfill'  => "\n\\hfill \n",
     '\noindent'        => "\n\\noindent \n",
     '\textbackslash'   => "\n\\backslash \n",
index 60c68779640a1a1e707cf0ecec22e78a1767706e..afb82aa12d7ba4b7d0e3e6b43e7efb6fd8f4a14e 100644 (file)
@@ -111,14 +111,15 @@ sub translate_preamble {
        "twocolumn"      => "\\papercolumns 2",
     );
 
-    # if the language file is available then added it to the options table
+    my %Languages_Table = ();
+    # if the language file is available then added it to the languages table
     if(-e "$main::lyxdir/languages") {
        open (LANGUAGES, "<$main::lyxdir/languages");
 
        while(<LANGUAGES>) {
            next if(/^\#/); #ignore comments
            my @lang_field = split(/\s+/);
-           $Option_Trans_Table{$lang_field[1]} = "\\language $lang_field[1]";
+           $Languages_Table{$lang_field[1]} = $lang_field[1];
        }
        close(LANGUAGES);
     }
@@ -203,6 +204,20 @@ sub translate_preamble {
            }
        }
        $extra_options =~ s/^,+|,+(?=,)|,+$//g; # extra commas
+       # Analyze further the extra options for languages, the last language
+       # is the document language, so the order matters.
+       my $language ="";
+       foreach $op (split(/\s*,\s*/,$extra_options)) {
+           if (exists $Languages_Table{$op}) {
+               $language = $op;
+               $extra_options =~ s/\b$op\b//;
+               print "Document language $op\n" if $debug_on;
+           }
+       }
+       if ($language) {
+           $LyX_Preamble .= "\\language $language\n";
+       }
+       $extra_options =~ s/^,+|,+(?=,)|,+$//g; # extra commas
     }
     # Convert any remaining options to an \options command
     if ($extra_options) {
@@ -214,14 +229,11 @@ sub translate_preamble {
     #     (unless there is no preamble)
     # Everything until the end of filehandle PREAMBLE is preamble matter
     my $Latex_Preamble = $_; # there COULD be a preamble command on same line
-    my $write_preamble = (! /^\s*$/ && ! /^\s*%/);
     while (<PREAMBLE>) {
        $Latex_Preamble .= $_;
-       # write an official preamble if we find anything that's not comment
-       $write_preamble ||= (! /^\s*$/ && ! /^\s*%/);
     }
 
-    # Process $Latex_Preamble, and try to extarct as much as possible to
+    # Process $Latex_Preamble, and try to extract as much as possible to
     # $Lyx_Preamble (jamatos 2001/07/21)
 
     # Deal with counters, for now just "tocdepth" and "secnumdepth"
@@ -245,7 +257,7 @@ sub translate_preamble {
     }
     $Latex_Preamble =~ s/\\usepackage\[.*\]\{fontenc\}\s*//;
 
-    ## Deal with several \usepackage{} cases
+    ## Deal with \usepackage{} cases, no optional argument
     my %Usepackage_Table = (
        "amsmath"       => "\\use_amsmath 1",
        "amssymb"       => "",
@@ -348,16 +360,12 @@ sub translate_preamble {
     $Latex_Preamble =~ s/\\makeatletter\s*//;
     $Latex_Preamble =~ s/\\makeatother\s*//;
 
-    if ($write_preamble) {
-       $Latex_Preamble =~ s/^\s*//;
-       print "LaTeX preamble, consists of:\n$Latex_Preamble" if $debug_on;
-       if($Latex_Preamble) {
-           $Latex_Preamble = "\\begin_preamble\n$Latex_Preamble\\end_preamble\n";
-       }
-       print "End of LaTeX preamble\n" if $debug_on;
-    } else {
-        $Latex_Preamble = ""; #just comments, whitespace. Ignore them
-    }
+    $Latex_Preamble =~ s/^\s*//;
+    print "LaTeX preamble, consists of:\n$Latex_Preamble" if $debug_on;
+    if($Latex_Preamble) {
+       $Latex_Preamble = "\\begin_preamble\n$Latex_Preamble\\end_preamble\n";
+    } #just comments, whitespace. Ignore them
+    print "End of LaTeX preamble\n" if $debug_on;
 
     #warn "Done creating LyX Preamble\n";
     return ($class, $LyX_Preamble, $Latex_Preamble);