]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/layout2layout.py
FindAdv: Ignore comment-feature (but not its content)
[lyx.git] / lib / scripts / layout2layout.py
index ad588bf7970c57dde717cb96438b7cdf3177d26e..88ada1213e1e1a62db4e0c38c72badf3b56bf047 100644 (file)
@@ -11,7 +11,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 75
+currentFormat = 95
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -250,6 +250,77 @@ currentFormat = 75
 
 # Incremented to format 75, 2 June 2019 by spitz
 # New Argument tags FreeSpacing, InsertOnNewline
+# New InsetLayout tag ParbreakIgnored
+
+# Incremented to format 76, 8 July 2019 by spitz
+# New textclass tag BibInToc
+
+# Incremented to format 77, 6 August 2019 by spitz
+# New textclass tag PageSize (= default page size)
+# and textclass option PageSize (= list of available page sizes)
+
+# Incremented to format 78, 6 August 2019 by spitz
+# New textclass tag FontsizeFormat
+
+# Incremented to format 79, 7 August 2019 by spitz
+# New textclass tag PagesizeFormat
+
+# Incremented to format 80, 12 August 2019 by spitz
+# New float option Requires
+
+# Incremented to format 81, 12 August 2019 by rikiheck
+# New tag GuiName for counters
+
+# Incremented to format 82, 4 June 2017 by tcuvelier
+# - Add new tags for Layout:
+#   DocBookTag, DocBookAttr, DocBookInInfo,
+#   DocBookWrapperTag, DocBookWrapperAttr,
+#   DocBookItemWrapperTag, DocBookItemWrapperAttr,
+#   DocBookItemTag, DocBookItemAttr,
+#   DocBookLabelTag, DocBookLabelAttr
+# - Removed tag Header from ClassOptionsClassOptions
+# - Removed tag Element for flex insets
+
+# Incremented to format 83, 2 August 2020 by tcuvelier
+# New tags DocBookWrapperMergeWithPrevious and DocBookAbstract
+
+# Incremented to format 84, 17 August 2020 by tcuvelier
+# New tags DocBookTagType, DocBookWrapperTagTagType,
+# DocBookItemWrapperTagTagType, DocBookItemTagTagType,
+# DocBookLabelTag
+
+# Incremented to format 85, 7 October 2020 by tcuvelier
+# New tags DocBookInnerTag, DocBookInnerAttr,
+# DocBookInnerTagType
+
+# Incremented to format 86, 20 October 2020 by tcuvelier
+# New tag DocBookSection.
+
+# Incremented to format 87, 2 November 2020 by rkh
+
+# Incremented to format 88, 28 November 2020 by tcuvelier
+# New tag DocBookNotInPara.
+
+# Incremented to format 89, 5 December 2020 by rkh
+# New tag LaTeXName for counters
+
+# Incremented to format 90, 11 December 2020 by spitz
+# Use semantic label colors
+
+# Incremented to format 91, 25 January 2021 by spitz
+# InputGlobal tag
+
+# Incremented to format 92, 30 January 2021 by spitz
+# Add ProvideInsetLayout and ModifyInsetLayout
+
+# Incremented to format 93, 13 February 2021 by spitz
+# Add DocBookNoFontInside
+
+# Incremented to format 94, 19 September 2021 by tcuvelier
+# Add DocBookFloatType, DocBookCaption
+
+# Incremented to format 95, 27 September 2021 by tcuvelier
+# Add DocBookRenderAsImage
 
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
@@ -283,7 +354,7 @@ def error(message):
 
 def trim_bom(line):
     " Remove byte order mark."
-    if line[0:3] == "\357\273\277":
+    if line[0:3] == b"\357\273\277":
         return line[3:]
     else:
         return line
@@ -311,6 +382,7 @@ def concatenate_label(old, new):
     else:
         return b'"' + old + new + b'"'
 
+
 # appends a string to a list unless it's already there
 def addstring(s, l):
     if l.count(s) > 0:
@@ -372,8 +444,8 @@ def convert(lines, end_format):
     # for categories
     re_Declaration = re.compile(b'^#\\s*\\Declare\\w+Class.*$')
     re_ExtractCategory = re.compile(b'^(#\\s*\\Declare\\w+Class(?:\\[[^]]*?\\])?){([^(]+?)\\s+\\(([^)]+?)\\)\\s*}\\s*$')
-    ConvDict = {"article": "Articles", "book" : "Books", "letter" : "Letters", "report": "Reports", \
-                "presentation" : "Presentations", "curriculum vitae" : "Curricula Vitae", "handout" : "Handouts"}
+    ConvDict = {b"article": b"Articles", b"book": b"Books", b"letter": b"Letters", b"report": b"Reports",
+                b"presentation": b"Presentations", b"curriculum vitae": b"Curricula Vitae", b"handout": b"Handouts"}
     # Arguments
     re_OptArgs = re.compile(b'^(\\s*)OptionalArgs(\\s+)(\\d+)\\D*$', re.IGNORECASE)
     re_ReqArgs = re.compile(b'^(\\s*)RequiredArgs(\\s+)(\\d+)\\D*$', re.IGNORECASE)
@@ -465,12 +537,12 @@ def convert(lines, end_format):
           continue
 
         # insert file format if not already there
-        if (only_comment):
+        if only_comment:
             match = re_Format.match(lines[i])
             if match:
                 formatline = i
                 format = int(match.group(4))
-                if format > 1 and format < end_format:
+                if 1 < format < end_format:
                     lines[i] = b"Format %d" % (format + 1)
                     only_comment = 0
                 elif format == end_format:
@@ -500,7 +572,38 @@ def convert(lines, end_format):
                 i += 1
             continue
 
-        if format >= 65 and format <= 74:
+        if 87 <= format <= 95:
+            # nothing to do.
+            i += 1
+            continue
+
+        if format == 86:
+            if lines[i].lstrip().lower().startswith(b"stepmastercounter"):
+                pattern = re.compile(b"stepmastercounter", re.IGNORECASE)
+                lines[i] = pattern.sub(b"StepParentCounter", lines[i])
+            i += 1
+            continue
+
+        if 82 <= format <= 85:
+            # nothing to do.
+            i += 1
+            continue
+
+        if format == 81:
+            match = re.compile(b'^(\\s*Header\\s+)("?\\w+"?)', re.IGNORECASE).match(lines[i])
+            if match:
+                del lines[i]
+                continue
+
+            match = re.compile(b'(\\s*LyXType\\s+)(\\w+)(\\s*Element\\s+)', re.IGNORECASE).match(lines[i])
+            if match:
+                del lines[i]
+                continue
+
+            i += 1
+            continue
+
+        if 65 <= format <= 80:
             # nothing to do.
             i += 1
             continue
@@ -512,7 +615,7 @@ def convert(lines, end_format):
                 continue
             col  = match.group(2)
             if col == "collapsable":
-                lines[i] = match.group(1) + "collapsible"
+                lines[i] = match.group(1) + b"collapsible"
             i += 1
             continue
 
@@ -525,7 +628,7 @@ def convert(lines, end_format):
             i += 1
             continue
 
-        if format >= 60 and format <= 62:
+        if 60 <= format <= 62:
             # nothing to do.
             i += 1
             continue
@@ -558,7 +661,7 @@ def convert(lines, end_format):
             i += 1
             continue
 
-        if format >= 50 and format <= 56:
+        if 50 <= format <= 56:
             # nothing to do.
             i += 1
             continue
@@ -656,7 +759,7 @@ def convert(lines, end_format):
 
             continue
 
-        if format >= 44 and format <= 47:
+        if 44 <= format <= 47:
             # nothing to do.
             i += 1
             continue
@@ -730,7 +833,7 @@ def convert(lines, end_format):
             # Insert the required number of arguments at the end of the style definition
             match = re_End.match(lines[i])
             if match:
-                newarg = ['']
+                newarg = [b'']
                 # First the optionals (this is the required order pre 2.1)
                 if opts > 0:
                     if opts == 1:
@@ -775,7 +878,7 @@ def convert(lines, end_format):
             continue
 
         if format == 36:
-            match = re_CiteFormat.match(lines[i]);
+            match = re_CiteFormat.match(lines[i])
             if match and match.group(4) == b"":
                 lines[i] = match.group(0) + b" default"
             i += 1
@@ -844,7 +947,7 @@ def convert(lines, end_format):
           continue
 
         # Only new features
-        if format >= 29 and format <= 31:
+        if 29 <= format <= 31:
           i += 1
           continue
 
@@ -868,7 +971,7 @@ def convert(lines, end_format):
           continue
 
         # Only new features
-        if format >= 24 and format <= 27:
+        if 24 <= format <= 27:
           i += 1
           continue
 
@@ -914,7 +1017,7 @@ def convert(lines, end_format):
           continue
 
         # This just involved new features, not any changes to old ones
-        if format >= 14 and format <= 22:
+        if 14 <= format <= 22:
           i += 1
           continue
 
@@ -991,7 +1094,7 @@ def convert(lines, end_format):
             continue
 
         # These just involved new features, not any changes to old ones
-        if format >= 5 and format <= 7:
+        if 5 <= format <= 7:
           i += 1
           continue
 
@@ -1180,7 +1283,7 @@ def convert(lines, end_format):
             if latextype == b"item_environment" and label.lower() == b"counter_enumi":
                 lines[labeltype_line] = re_LabelType.sub(b'\\1\\2\\3Enumerate', lines[labeltype_line])
                 # Don't add the LabelCounter line later
-                counter = ""
+                counter = b""
 
             # Replace
             #
@@ -1253,13 +1356,17 @@ def main(argv):
     # Open files
     if options.input_file:
         source = open(options.input_file, 'rb')
-    else:
+    elif PY2:
         source = sys.stdin
+    else:
+        source = sys.stdin.buffer
 
     if options.output_file:
         output = open(options.output_file, 'wb')
-    else:
+    elif PY2:
         output = sys.stdout
+    else:
+        output = sys.stdout.buffer
 
     if options.format > currentFormat:
         error("Format %i does not exist" % options.format);