The bug is that older layout files with lines like:
Input amsmaths.inc
fail in 1.6, since that file no longer exists. This commit adds some
layout2layout that will scan for such includes and add lines like
UseModule theorems-ams
corresponding to the input lines. The downside to this commit is that
UseModule only becomes available on 25 July 2008, whereas the files
were removed in January.
My intention is to try to deal with these intermediate cases as well.
But I'm not sure that will ultimately work very well, so this will do
until I can figure that out.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26800
a592a061-630c-0410-9148-
cb99ea01b6c8
else:
return '"' + old + new + '"'
else:
return '"' + old + new + '"'
+# appends a string to a list unless it's already there
+def addstring(s, l):
+ if l.count(s) > 0:
+ return
+ l.append(s)
+
def convert(lines):
" Convert to new format."
re_Comment = re.compile(r'^(\s*)#')
def convert(lines):
" Convert to new format."
re_Comment = re.compile(r'^(\s*)#')
- re_Counter = re.compile(r'\s*Counter\s*')
- re_Name = re.compile(r'\s*Name\s+(\S+)\s*')
+ re_Counter = re.compile(r'\s*Counter\s*', re.IGNORECASE)
+ re_Name = re.compile(r'\s*Name\s+(\S+)\s*', re.IGNORECASE)
re_Empty = re.compile(r'^(\s*)$')
re_Format = re.compile(r'^(\s*)(Format)(\s+)(\S+)', re.IGNORECASE)
re_Preamble = re.compile(r'^(\s*)Preamble', re.IGNORECASE)
re_Empty = re.compile(r'^(\s*)$')
re_Format = re.compile(r'^(\s*)(Format)(\s+)(\S+)', re.IGNORECASE)
re_Preamble = re.compile(r'^(\s*)Preamble', re.IGNORECASE)
re_End = re.compile(r'^(\s*)(End)(\s*)$', re.IGNORECASE)
re_Provides = re.compile(r'^(\s*)Provides(\S+)(\s+)(\S+)', re.IGNORECASE)
re_CharStyle = re.compile(r'^(\s*)CharStyle(\s+)(\S+)$', re.IGNORECASE)
re_End = re.compile(r'^(\s*)(End)(\s*)$', re.IGNORECASE)
re_Provides = re.compile(r'^(\s*)Provides(\S+)(\s+)(\S+)', re.IGNORECASE)
re_CharStyle = re.compile(r'^(\s*)CharStyle(\s+)(\S+)$', re.IGNORECASE)
+ re_AMSMaths = re.compile(r'^\s*Input amsmaths.inc\s*')
+ re_AMSMathsPlain = re.compile(r'^\s*Input amsmaths-plain.inc\s*')
+ re_AMSMathsSeq = re.compile(r'^\s*Input amsmaths-seq.inc\s*')
# counters for sectioning styles (hardcoded in 1.3)
counters = {"part" : "\\Roman{part}",
# counters for sectioning styles (hardcoded in 1.3)
counters = {"part" : "\\Roman{part}",
style = ""
maxcounter = 0
format = 1
style = ""
maxcounter = 0
format = 1
+ formatline = 0
+ usemodules = []
+
while i < len(lines):
# Skip comments and empty lines
if re_Comment.match(lines[i]) or re_Empty.match(lines[i]):
while i < len(lines):
# Skip comments and empty lines
if re_Comment.match(lines[i]) or re_Empty.match(lines[i]):
if (only_comment):
match = re_Format.match(lines[i])
if match:
if (only_comment):
match = re_Format.match(lines[i])
if match:
format = int(match.group(4))
if format > 1 and format < currentFormat:
lines[i] = "Format %d" % (format + 1)
format = int(match.group(4))
if format > 1 and format < currentFormat:
lines[i] = "Format %d" % (format + 1)
+ if format == 8:
+ # We want to scan for ams-type includes and, if we find them,
+ # add corresponding UseModule tags to the layout.
+ match = re_AMSMaths.match(lines[i])
+ if match:
+ addstring("theorems-ams", usemodules)
+ addstring("theorems-ams-extended", usemodules)
+ addstring("theorems-sec", usemodules)
+ lines.pop(i)
+ continue
+ match = re_AMSMathsPlain.match(lines[i])
+ if match:
+ addstring("theorems-starred", usemodules)
+ lines.pop(i)
+ continue
+ match = re_AMSMathsSeq.match(lines[i])
+ if match:
+ addstring("theorems-ams", usemodules)
+ addstring("theorems-ams-extended", usemodules)
+ lines.pop(i)
+ continue
+ i += 1
+ continue
+
# These just involved new features, not any changes to old ones
# These just involved new features, not any changes to old ones
- if format >= 5 and format <= 8:
+ if format >= 5 and format <= 7:
+ if usemodules:
+ i = formatline + 1
+ for mod in usemodules:
+ lines.insert(i, "UseModule " + mod)
+ i += 1
+