]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/layout2layout.py
Spanish manuals: updates by Ignacio and me
[lyx.git] / lib / scripts / layout2layout.py
index e26c811de1f7cc37b10e489c25f5422faa12bd25..782a02637ec1b182520946b05574b0e60ae49d13 100644 (file)
@@ -84,6 +84,16 @@ import os, re, string, sys
 # Incremented to format 23, 13 February 2010 by spitz
 # Added Spellcheck tag.
 
+# Incremented to format 24, 5 March 2010 by rgh
+# Changed LaTeXBuiltin tag to NeedsFloatPkg and
+# added new tag ListCommand.
+
+# Incremented to format 25, 12 March 2010 by rgh
+# Added RefPrefix tag for layouts and floats.
+
+# Incremented to format 26, 29 March 2010 by rgh
+# Added CiteFormat.
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -91,7 +101,7 @@ import os, re, string, sys
 # development/tools/updatelayouts.sh script to update all
 # layout files to the new format.
 
-currentFormat = 23
+currentFormat = 26
 
 
 def usage(prog_name):
@@ -171,6 +181,10 @@ def convert(lines):
     re_TocLevel = re.compile(r'^(\s*)(TocLevel)(\s+)(\S+)', re.IGNORECASE)
     re_I18nPreamble = re.compile(r'^(\s*)I18nPreamble', re.IGNORECASE)
     re_EndI18nPreamble = re.compile(r'^(\s*)EndI18nPreamble', re.IGNORECASE)
+    re_Float = re.compile(r'^\s*Float\s*$', re.IGNORECASE)
+    re_Type = re.compile(r'\s*Type\s+(\w+)', re.IGNORECASE)
+    re_Builtin = re.compile(r'^(\s*)LaTeXBuiltin\s+(\w*)', re.IGNORECASE)
+    re_True = re.compile(r'^\s*(?:true|1)\s*$', re.IGNORECASE)
 
     # counters for sectioning styles (hardcoded in 1.3)
     counters = {"part"          : "\\Roman{part}",
@@ -258,7 +272,53 @@ def convert(lines):
             while i < len(lines) and not re_EndBabelPreamble.match(lines[i]):
                 i += 1
             continue
+        
+        # Only new features
+        if format >= 24 and format <= 25:
+            i += 1
+            continue
 
+        if format == 23:
+          match = re_Float.match(lines[i])
+          i += 1
+          if not match:
+            continue
+          # we need to do two things:
+          # (i)  Convert Builtin to NeedsFloatPkg
+          # (ii) Write ListCommand lines for the builtin floats table and figure
+          builtin = False
+          cmd = ""
+          while True and i < len(lines):
+            m1 = re_End.match(lines[i])
+            if m1:
+              if builtin and cmd:
+                line = "    ListCommand " + cmd
+                lines.insert(i, line)
+                i += 1
+              break
+            m2 = re_Builtin.match(lines[i])
+            if m2:
+              builtin = True
+              ws1 = m2.group(1)
+              arg = m2.group(2)
+              newarg = ""
+              if re_True.match(arg):
+                newarg = "false"
+              else:
+                newarg = "true"
+              lines[i] = ws1 + "NeedsFloatPkg " + newarg
+            m3 = re_Type.match(lines[i])
+            if m3:
+              fltype = m3.group(1)
+              fltype = fltype.lower()
+              if fltype == "table":
+                cmd = "listoftables"
+              elif fltype == "figure":
+                cmd = "listoffigures"
+              # else unknown, which is why we're doing this
+            i += 1
+          continue              
+          
         # This just involved new features, not any changes to old ones
         if format >= 14 and format <= 22:
           i += 1