From b5e2fd7bb76f18efeac0f75769ef7113cd08ab2b Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 12 Oct 2012 09:49:10 -0400 Subject: [PATCH] Fix layout2layout conversion for format 40. This is a big ugly, I'm afraid, but it's going to be. We skip all comment lines at the start of the script, but what we want to convert here is in those comment lines. My previous attempt to deal with this issue produced an invalid file. --- lib/scripts/layout2layout.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 1248c7f05c..a20ba900e8 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -296,12 +296,23 @@ def convert(lines): flexstyles = [] while i < len(lines): - # Skip comments and empty lines, but not if it's the declaration - # line (we'll deal with it below) - if (re_Comment.match(lines[i]) or re_Empty.match(lines[i])) \ - and not re_Declaration.match(lines[i]): - i += 1 - continue + # Skip comments and empty lines + if (re_Comment.match(lines[i]) or re_Empty.match(lines[i])): + # We need to deal with this conversion here, because it happens + # inside the initial comment block. + if only_comment and format == 39: + match = re_ExtractCategory.match(lines[i]) + if match: + lpre = match.group(1) + lcat = match.group(2) + lnam = match.group(3) + if lcat in ConvDict: + lcat = ConvDict[lcat] + lines[i] = lpre + "{" + lnam + "}" + lines.insert(i+1, "# \\DeclareCategory{" + lcat + "}") + i += 1 + i += 1 + continue # insert file format if not already there if (only_comment): @@ -340,16 +351,6 @@ def convert(lines): continue if format == 39: - match = re_ExtractCategory.match(lines[i]) - if match: - lpre = match.group(1) - lcat = match.group(2) - lnam = match.group(3) - if lcat in ConvDict: - lcat = ConvDict[lcat] - lines[i] = lpre + "{" + lnam + "}" - lines.insert(i+1, "# \\DeclareCategory{" + lcat + "}") - i += 1 i += 1 continue -- 2.39.2