Hi,

I have been playing a bit more with the linuxdoc-tools problem, now related
to LaTeX. I am attaching a patch for your consideration. It is somewhat
intrusive, but I think it does things in a more flexible way than current
code does. mapping files write options as e.q. @CLASSOPTIONS@ which are
substituted by the right value in fmt_latex2e.pl.

I think this patch should take care of:

#197914: linuxdoc-tools: language problem. Hard coded "english". patch given.
#259266: linuxdoc-tools: sgml2latex changes all \documentclass occurrences,
         not only the heading one

It also fixes a minor issue (non escaped []) introduced in

#322000: linuxdoc-tools: Obsolete code in generated LaTeX input files

Hope this helps

-- 
Agustin
Los ficheros binarios /tmp/3DghH1vcyN/linuxdoc-tools-0.9.21/debian/changelog y 
/tmp/u2kzvofSWz/linuxdoc-tools-0.9.21/debian/changelog son distintos
diff -Nru /tmp/3DghH1vcyN/linuxdoc-tools-0.9.21/lib/dist/fmt_latex2e.pl 
/tmp/u2kzvofSWz/linuxdoc-tools-0.9.21/lib/dist/fmt_latex2e.pl
--- /tmp/3DghH1vcyN/linuxdoc-tools-0.9.21/lib/dist/fmt_latex2e.pl       
2001-12-02 03:32:13.000000000 +0100
+++ /tmp/u2kzvofSWz/linuxdoc-tools-0.9.21/lib/dist/fmt_latex2e.pl       
2006-03-15 17:50:10.000000000 +0100
@@ -132,7 +132,7 @@
     {
       if (/^-/)
         {
-           my ($str) = $';
+           my ($str) = $'; #' Dumy for the colorizer
            chop ($str);
            $_ = parse_data ($str, $char_maps, $latex2e_escape);
            if ($remove_comment)
@@ -226,10 +226,10 @@
 #
 $latex2e->{postASP} = sub
 {
-  my $infile = shift;
-  my $filename = $global->{filename};
-  my $tmplatexdir = $global->{tmpbase} . "-latex-" . $$ . ".dir";
-  my $tmplatexnam = $tmplatexdir . "/" . $filename;
+  my $infile       = shift;
+  my $filename     = $global->{filename};
+  my $tmplatexdir  = $global->{tmpbase} . "-latex-" . $$ . ".dir";
+  my $tmplatexnam  = $tmplatexdir . "/" . $filename;
   my @epsfiles = ();
   my @texlines = ();
   my @urldefines = ();
@@ -298,51 +298,85 @@
   }
 
   open OUTFILE, ">$tmplatexnam.tex";
-  #
-  #  Set the correct \documentclass options.
-  #
+
+  # --------------------------------------------------------------------
+  #  Set the correct \documentclass and packages options.
+  # --------------------------------------------------------------------
     {
       my $langlit = ISO2English ($global->{language});
-      $langlit = ($langlit eq 'english') ? "" : ",$langlit"; 
-      my $replace = $global->{papersize} . 'paper' .   $langlit;
+      $langlit = ($langlit eq 'english') ? "" : "$langlit"; 
       my $hlatexopt = "";
       $global->{charset} = "nippon" if ($global->{language} eq "ja");
       $global->{charset} = "euc-kr" if ($global->{language} eq "ko");
-      $replace = $global->{papersize} . 'paper' if ($global->{charset} eq 
"nippon") || ($global->{charset} eq "euc-kr");
+      
+      # Getting document class prefix
+      my $classprefix = "";
+      if ($global->{charset} eq "nippon") {
+         if ($latex2e->{latex} eq "platex") {
+             $classprefix = "j";
+         } elsif ($latex2e->{latex} eq "jlatex") {
+             $classprefix = "j-";
+         }
+      }
+      # Getting class options
+      my $classoptions = $global->{papersize} . 'paper';
+      
+      # Getting babel options
+      my $babeloptions = $langlit || "english";
+      if (($global->{charset} eq "nippon") || 
+         ($global->{charset} eq "euc-kr")) {
+         $babeloptions = '';
+      }
+      
       while (defined($texlines[0]))
-        {
+      {
          $_ = shift @texlines;
-          if (/^\\documentclass/) 
-           {
-             if ($global->{language} ne "en" ||
-                 $global->{papersize} ne "a4")
-               {
-                  s/\\documentclass\[.*\]/\\documentclass\[$replace\]/;
-               }
-             if ($global->{charset} eq "nippon") {
-                if ($latex2e->{latex} eq "platex") {
-                  s/{article}/{jarticle}/;
-                } elsif ($latex2e->{latex} eq "jlatex") {
-                  s/{article}/{j-article}/;
-                }
-             }
+         
+         # Set right class name and options in the header
+         if (/[EMAIL PROTECTED]@\]/) 
+         {
+             s/\@(ARTICLE|REPORT|BOOK)\@/$classprefix . lc($1)/e;
+             s/[EMAIL PROTECTED]@/$classoptions/;
               $_ = $_ . "\\makeindex\n" if ($latex2e->{makeindex});
-            }
+         }
+         
+         # Set right babel options
+         if (/[EMAIL PROTECTED]@\]{babel}/) 
+         {
+             if ( $babeloptions ) {
+                 s/[EMAIL PROTECTED]@/$babeloptions/;
+             } else {
+                 s/^/%%/;
+             }
+         }
+         
           if (/^\\usepackage.epsfig/ && ($global->{charset} eq "euc-kr"))
             {
               $hlatexopt = "[noautojosa]" if ($latex2e->{latex} eq "hlatexp");
               $_ = $_ . "\\usepackage" . "$hlatexopt" . "{hangul}\n"
             }
-          if ((/\\usepackage.t1enc/) &&
-                (($global->{charset} eq "nippon") || 
-                 ($global->{charset} eq "euc-kr")))
-            {
-               s/^/%%/;
-            }
+
+         # Deal with input encoding
+          if ( /[EMAIL PROTECTED]@\]\{inputenc\}/ ) {
+             if ( $global->{charset} eq "latin" ) {
+                 s/[EMAIL PROTECTED]@/latin1/;
+             } else {
+                 s/^/%%/;
+             }
+         }
+         
+         # nippon or euc-kr do not use T1 encoding
+         if ((/\\usepackage\[T1\]\{fontenc\}/) &&
+             (($global->{charset} eq "nippon") || 
+              ($global->{charset} eq "euc-kr")))
+         {
+             s/^/%%/;
+         }
+         
           if (/%end-preamble/)
-           {
+         {
              if ($latex2e->{pagenumber}) 
-                {
+             {
                  $_ = $_ . '\setcounter{page}{'. 
                       $latex2e->{pagenumber} . "}\n";
                } 
diff -Nru 
/tmp/3DghH1vcyN/linuxdoc-tools-0.9.21/lib/dist/linuxdoc-tools/latex2e/mapping 
/tmp/u2kzvofSWz/linuxdoc-tools-0.9.21/lib/dist/linuxdoc-tools/latex2e/mapping
--- 
/tmp/3DghH1vcyN/linuxdoc-tools-0.9.21/lib/dist/linuxdoc-tools/latex2e/mapping   
    2005-12-25 13:00:36.000000000 +0100
+++ 
/tmp/u2kzvofSWz/linuxdoc-tools-0.9.21/lib/dist/linuxdoc-tools/latex2e/mapping   
    2006-03-15 17:47:16.000000000 +0100
@@ -6,16 +6,16 @@
 <qwertz>       +     
 </qwertz>      +
 
-<article>      + "\\documentclass\[a4paper\]{article}\n"
+<article>      + "[EMAIL PROTECTED]@[EMAIL PROTECTED]@}\n"
                        "\\usepackage{ifpdf}\n"
                        "\\usepackage{linuxdoc-sgml}\n"
                        "\\usepackage{qwertz}\n"
                        "\\usepackage{url}\n"
-                       "\\usepackage\[latin1\]{inputenc}\n"
-                        "\\usepackage[T1]{fontenc}\n"
+                       "[EMAIL PROTECTED]@\]{inputenc}\n"
+                        "\\usepackage\[T1\]{fontenc}\n"
                         
"\\usepackage\[colorlinks=true,urlcolor=blue,linkcolor=blue\]{hyperref}\n"
                         "\\pdfcompresslevel=9\n"
-                       "\\usepackage\[english\]{babel}\n"
+                       "[EMAIL PROTECTED]@\]{babel}\n"
                        "\\usepackage{epsfig}\n"
                        "\\usepackage{[OPTS]}\n"
                        "\\def\\addbibtoc{\n"
@@ -24,13 +24,13 @@
 
 </article>     +       "\\end{document}"       +
 
-<report>       + "\\documentclass\[a4paper\]{report}\n"
+<report>       + "[EMAIL PROTECTED]@[EMAIL PROTECTED]@}\n"
                        "\\usepackage{ifpdf}\n"
                        "\\usepackage{linuxdoc-sgml}\n"
                        "\\usepackage{qwertz}\n"
                        "\\usepackage{url}\n"
-                       "\\usepackage\[latin1\]{inputenc}\n"
-                        "\\usepackage[T1]{fontenc}\n"
+                       "[EMAIL PROTECTED]@\]{inputenc}\n"
+                        "\\usepackage\[T1\]{fontenc}\n"
                         
"\\usepackage\[colorlinks=true,urlcolor=blue,linkcolor=blue\]{hyperref}\n"
                         "\\pdfcompresslevel=9\n"
                        "\\usepackage\[english\]{babel}\n"
@@ -43,13 +43,13 @@
 
 </report>      +       "\\end{document}"       +
 
-<book> +       "\\documentclass\[a4paper\]{book}\n"
+<book> +       "[EMAIL PROTECTED]@[EMAIL PROTECTED]@}\n"
                        "\\usepackage{ifpdf}\n"
                        "\\usepackage{linuxdoc-sgml}\n"
                        "\\usepackage{qwertz}\n"
                        "\\usepackage{url}\n"
-                       "\\usepackage\[latin1\]{inputenc}\n"
-                        "\\usepackage[T1]{fontenc}\n"
+                       "[EMAIL PROTECTED]@\]{inputenc}\n"
+                        "\\usepackage\[T1\]{fontenc}\n"
                         
"\\usepackage\[colorlinks=true,urlcolor=blue,linkcolor=blue\]{hyperref}\n"
                         "\\pdfcompresslevel=9\n"
                        "\\usepackage\[english\]{babel}\n"
@@ -63,13 +63,13 @@
 </book>                +       "\\end{document}"       +
 
 
-<notes> +      "\\documentclass\[a4paper\]{article}\n"
+<notes> +      "[EMAIL PROTECTED]@[EMAIL PROTECTED]@}\n"
                        "\\usepackage{ifpdf}\n"
                        "\\usepackage{linuxdoc-sgml}\n"
                        "\\usepackage{qwertz}\n"
                        "\\usepackage{url}\n"
-                       "\\usepackage\[latin1\]{inputenc}\n"
-                        "\\usepackage[T1]{fontenc}\n"
+                       "[EMAIL PROTECTED]@\]{inputenc}\n"
+                        "\\usepackage\[T1\]{fontenc}\n"
                         
"\\usepackage\[colorlinks=true,urlcolor=blue,linkcolor=blue\]{hyperref}\n"
                         "\\pdfcompresslevel=9\n"
                        "\\usepackage\[english\]{babel}\n"
diff -Nru 
/tmp/3DghH1vcyN/linuxdoc-tools-0.9.21/lib/dist/linuxdoc-tools/latex2e/tr-mapping
 
/tmp/u2kzvofSWz/linuxdoc-tools-0.9.21/lib/dist/linuxdoc-tools/latex2e/tr-mapping
--- 
/tmp/3DghH1vcyN/linuxdoc-tools-0.9.21/lib/dist/linuxdoc-tools/latex2e/tr-mapping
    2005-12-25 13:00:36.000000000 +0100
+++ 
/tmp/u2kzvofSWz/linuxdoc-tools-0.9.21/lib/dist/linuxdoc-tools/latex2e/tr-mapping
    2006-03-15 17:47:54.000000000 +0100
@@ -6,16 +6,16 @@
 <qwertz>       +     
 </qwertz>      +
 
-<article>      + "\\documentclass\[a4paper\]{article}\n"
+<article>      + "[EMAIL PROTECTED]@[EMAIL PROTECTED]@}\n"
                        "\\usepackage{ifpdf}\n"
                        "\\usepackage{linuxdoctr-sgml}\n"
                        "\\usepackage{qwertz}\n"
                        "\\usepackage{url}\n"
-                       "\\usepackage\[latin1\]{inputenc}\n"
-                        "\\usepackage[T1]{fontenc}\n"
+                       "[EMAIL PROTECTED]@\]{inputenc}\n"
+                        "\\usepackage\[T1\]{fontenc}\n"
                         
"\\usepackage\[colorlinks=true,urlcolor=blue,linkcolor=blue\]{hyperref}\n"
                         "\\pdfcompresslevel=9\n"
-                       "\\usepackage\[english\]{babel}\n"
+                       "[EMAIL PROTECTED]@\]{babel}\n"
                        "\\usepackage{epsfig}\n"
                        "\\usepackage{[OPTS]}\n"
                        "\\def\\addbibtoc{\n"
@@ -24,13 +24,13 @@
 
 </article>     +       "\\end{document}"       +
 
-<report>       + "\\documentclass\[a4paper\]{report}\n"
+<report>       + "[EMAIL PROTECTED]@[EMAIL PROTECTED]@}\n"
                        "\\usepackage{ifpdf}\n"
                        "\\usepackage{linuxdoctr-sgml}\n"
                        "\\usepackage{qwertz}\n"
                        "\\usepackage{url}\n"
-                       "\\usepackage\[latin1\]{inputenc}\n"
-                        "\\usepackage[T1]{fontenc}\n"
+                       "[EMAIL PROTECTED]@\]{inputenc}\n"
+                        "\\usepackage\[T1\]{fontenc}\n"
                         
"\\usepackage\[colorlinks=true,urlcolor=blue,linkcolor=blue\]{hyperref}\n"
                         "\\pdfcompresslevel=9\n"
                        "\\usepackage\[english\]{babel}\n"
@@ -43,13 +43,13 @@
 
 </report>      +       "\\end{document}"       +
 
-<book> +       "\\documentclass\[a4paper\]{book}\n"
+<book> +       "[EMAIL PROTECTED]@[EMAIL PROTECTED]@}\n"
                        "\\usepackage{ifpdf}\n"
                        "\\usepackage{linuxdoctr-sgml}\n"
                        "\\usepackage{qwertz}\n"
                        "\\usepackage{url}\n"
-                       "\\usepackage\[latin1\]{inputenc}\n"
-                        "\\usepackage[T1]{fontenc}\n"
+                       "[EMAIL PROTECTED]@\]{inputenc}\n"
+                        "\\usepackage\[T1\]{fontenc}\n"
                         
"\\usepackage\[colorlinks=true,urlcolor=blue,linkcolor=blue\]{hyperref}\n"
                         "\\pdfcompresslevel=9\n"
                        "\\usepackage\[english\]{babel}\n"
@@ -63,13 +63,13 @@
 </book>                +       "\\end{document}"       +
 
 
-<notes> +      "\\documentclass\[a4paper\]{article}\n"
+<notes> +      "[EMAIL PROTECTED]@[EMAIL PROTECTED]@}\n"
                        "\\usepackage{ifpdf}\n"
                        "\\usepackage{linuxdoctr-sgml}\n"
                        "\\usepackage{qwertz}\n"
                        "\\usepackage{url}\n"
-                       "\\usepackage\[latin1\]{inputenc}\n"
-                        "\\usepackage[T1]{fontenc}\n"
+                       "[EMAIL PROTECTED]@\]{inputenc}\n"
+                        "\\usepackage\[T1\]{fontenc}\n"
                         
"\\usepackage\[colorlinks=true,urlcolor=blue,linkcolor=blue\]{hyperref}\n"
                         "\\pdfcompresslevel=9\n"
                        "\\usepackage\[english\]{babel}\n"

Reply via email to