]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/layout2layout.py
fix: http://bugzilla.lyx.org/show_bug.cgi?id=452
[lyx.git] / lib / scripts / layout2layout.py
index 08e5058b587fb9c3ed2f89ffba9ae0610e40d3dd..59e43e743e8533d2f6f0c8ef86789595617c41c6 100644 (file)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+# -*- coding: utf-8 -*-
 
 # file layout2layout.py
 # This file is part of LyX, the document processor.
@@ -82,18 +82,18 @@ def convert(lines):
     counters = {"part"          : "\\Roman{part}",
                 "chapter"       : "\\arabic{chapter}",
                 "section"       : "\\arabic{section}",
-                "subsection"    : "@Section@.\\arabic{subsection}",
-                "subsubsection" : "@Subsection@.\\arabic{subsubsection}",
-                "paragraph"     : "@Subsubsection@.\\arabic{paragraph}",
-                "subparagraph"  : "@Paragraph@.\\arabic{subparagraph}"}
+                "subsection"    : "\\arabic{section}.\\arabic{subsection}",
+                "subsubsection" : "\\arabic{section}.\\arabic{subsection}.\\arabic{subsubsection}",
+                "paragraph"     : "\\arabic{section}.\\arabic{subsection}.\\arabic{subsubsection}.\\arabic{paragraph}",
+                "subparagraph"  : "\\arabic{section}.\\arabic{subsection}.\\arabic{subsubsection}.\\arabic{paragraph}.\\arabic{subparagraph}"}
 
     # counters for sectioning styles in appendix (hardcoded in 1.3)
     appendixcounters = {"chapter"       : "\\Alph{chapter}",
                         "section"       : "\\Alph{section}",
-                        "subsection"    : "@Section@.\\arabic{subsection}",
-                        "subsubsection" : "@Subsection@.\\arabic{subsubsection}",
-                        "paragraph"     : "@Subsubsection@.\\arabic{paragraph}",
-                        "subparagraph"  : "@Paragraph@.\\arabic{subparagraph}"}
+                        "subsection"    : "\\arabic{section}.\\arabic{subsection}",
+                        "subsubsection" : "\\arabic{section}.\\arabic{subsection}.\\arabic{subsubsection}",
+                        "paragraph"     : "\\arabic{section}.\\arabic{subsection}.\\arabic{subsubsection}.\\arabic{paragraph}",
+                        "subparagraph"  : "\\arabic{section}.\\arabic{subsection}.\\arabic{subsubsection}.\\arabic{paragraph}.\\arabic{subparagraph}"}
 
     # Value of TocLevel for sectioning styles
     toclevels = {"part"          : 0,
@@ -114,6 +114,7 @@ def convert(lines):
     labelstring_line = -1
     labelstringappendix_line = -1
     labeltype_line = -1
+    latextype = ""
     latextype_line = -1
     style = ""
     maxcounter = 0
@@ -134,7 +135,7 @@ def convert(lines):
                                 return
                         error('Cannot convert file format %s' % format)
                 else:
-                       lines.insert(i, "Format 2")
+                        lines.insert(i, "Format 2")
                         only_comment = 0
                         continue
 
@@ -206,6 +207,7 @@ def convert(lines):
         # Remember the LatexType line
         match = re_LatexType.match(lines[i])
         if match:
+            latextype = string.lower(match.group(4))
             latextype_line = i
 
         # Reset variables at the beginning of a style definition
@@ -220,6 +222,7 @@ def convert(lines):
             labelstring_line = -1
             labelstringappendix_line = -1
             labeltype_line = -1
+            latextype = ""
             latextype_line = -1
 
         if re_End.match(lines[i]):
@@ -233,6 +236,16 @@ def convert(lines):
                 else:
                     lines[latextype_line] = re_LatexType.sub(r'\1\2\3Bib_Environment', lines[latextype_line])
 
+            # Change "LabelType Static" to "LabelType Itemize" for itemize environments
+            if latextype == "item_environment" and string.lower(label) == "static":
+                lines[labeltype_line] = re_LabelType.sub(r'\1\2\3Itemize', lines[labeltype_line])
+
+            # Change "LabelType Counter_EnumI" to "LabelType Enumerate" for enumerate environments
+            if latextype == "item_environment" and string.lower(label) == "counter_enumi":
+                lines[labeltype_line] = re_LabelType.sub(r'\1\2\3Enumerate', lines[labeltype_line])
+                # Don't add the LabelCounter line later
+                counter = ""
+
             # Replace
             #
             # LabelString "Chapter"
@@ -269,7 +282,7 @@ def convert(lines):
                 i = i + 1
 
             # Add the TocLevel setting for sectioning styles
-           if toclevels.has_key(style) and maxcounter <= toclevels[style]:
+            if toclevels.has_key(style) and maxcounter <= toclevels[style]:
                 lines.insert(i, '%sTocLevel %d' % (space1, toclevels[style]))
                 i = i + 1