X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Fscripts%2Flayout2layout.py;h=a59dfcfae2afbd3425278d44a4f8ee17edf69e90;hb=897edc10c07f5605584317376d7e909e1eba9319;hp=857776b32116eaeec32baeff16a23f25b10ca15e;hpb=e6ec7bdce547f55f8eb6df72155bceecd93d6b2a;p=lyx.git diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 857776b321..a59dfcfae2 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -116,6 +116,12 @@ import os, re, string, sys # Incremented to format 33, 2 February 2011 by rgh # Changed NeedsFloatPkg to UsesFloatPkg +# Incremented to format 34, 28 March 2011 by rgh +# Remove obsolete Fill_(Top|Bottom) tags + +# Incremented to format 35, 28 March 2011 by rgh +# Try to add "Flex:" to any flex insets that don't have it. + # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). @@ -123,7 +129,7 @@ import os, re, string, sys # development/tools/updatelayouts.sh script to update all # layout files to the new format. -currentFormat = 33 +currentFormat = 35 def usage(prog_name): @@ -207,12 +213,18 @@ def convert(lines): 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) - re_InsetLayout = re.compile(r'^\s*InsetLayout\s+(?:Custom|CharStyle|Element):(\S+)\s*$') + re_InsetLayout = re.compile(r'^\s*InsetLayout\s+(?:Custom|CharStyle|Element):(\S+)\s*$', re.IGNORECASE) + # with quotes + re_QInsetLayout = re.compile(r'^\s*InsetLayout\s+"(?:Custom|CharStyle|Element):([^"]+)"\s*$', re.IGNORECASE) + re_InsetLayout_CopyStyle = re.compile(r'^\s*CopyStyle\s+(?:Custom|CharStyle|Element):(\S+)\s*$', re.IGNORECASE) + re_QInsetLayout_CopyStyle = re.compile(r'^\s*CopyStyle\s+"(?:Custom|CharStyle|Element):([^"]+)"\s*$', re.IGNORECASE) + re_NeedsFloatPkg = re.compile(r'^(\s*)NeedsFloatPkg\s+(\w+)\s*$', re.IGNORECASE) + re_Fill = re.compile(r'^\s*Fill_(?:Top|Bottom).*$', re.IGNORECASE) + re_InsetLayout2 = re.compile(r'^\s*InsetLayout\s+(\S+)\s*$', re.IGNORECASE) # with quotes - re_QInsetLayout = re.compile(r'^\s*InsetLayout\s+"(?:Custom|CharStyle|Element):([^"]+)"\s*$') - re_InsetLayout_CopyStyle = re.compile(r'^\s*CopyStyle\s+(?:Custom|CharStyle|Element):(\S+)\s*$') - re_QInsetLayout_CopyStyle = re.compile(r'^\s*CopyStyle\s+"(?:Custom|CharStyle|Element):([^"]+)"\s*$') - re_NeedsFloatPkg = re.compile(r'^(\s*)NeedsFloatPkg\s+(\w+)\s*$') + re_QInsetLayout2 = re.compile(r'^\s*InsetLayout\s+"([^"]+)"\s*$', re.IGNORECASE) + re_IsFlex = re.compile(r'\s*LyXType.*$', re.IGNORECASE) + re_CopyStyle2 = re.compile(r'(\s*CopyStyle\s+)"?([^"]+)"?\s*$') # counters for sectioning styles (hardcoded in 1.3) counters = {"part" : "\\Roman{part}", @@ -258,6 +270,7 @@ def convert(lines): format = 1 formatline = 0 usemodules = [] + flexstyles = [] while i < len(lines): # Skip comments and empty lines @@ -301,6 +314,50 @@ def convert(lines): i += 1 continue + if format == 34: + match = re_InsetLayout2.match(lines[i]) + if not match: + match = re_QInsetLayout2.match(lines[i]) + if not match: + match = re_CopyStyle2.match(lines[i]) + if not match: + i += 1 + continue + style = match.group(2) + + if flexstyles.count(style): + lines[i] = match.group(1) + "\"Flex:" + style + "\"" + i += 1 + continue + + name = match.group(1) + names = name.split(":", 1) + if len(names) > 1 and names[0] == "Flex": + i += 1 + continue + + isflex = False + for j in range(i + 1, len(lines)): + if re_IsFlex.match(lines[j]): + isflex = True + break + if re_End.match(lines[j]): + break + + if isflex: + flexstyles.append(name) + lines[i] = "InsetLayout \"Flex:" + name + "\"" + + i += 1 + continue + + if format == 33: + m = re_Fill.match(lines[i]) + if m: + lines[i] = "" + i += 1 + continue + if format == 32: match = re_NeedsFloatPkg.match(lines[i]) if match: