]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx_2_4.py
ePub: share a bit of code for parsing arguments.
[lyx.git] / lib / lyx2lyx / lyx_2_4.py
index 104ca00a106908077a5077f69c967e1d08825355..2ea050e6ee995cfbe984a2de4fe3d2500dfacbdd 100644 (file)
@@ -4222,7 +4222,17 @@ def revert_vcolumns2(document):
                                 if el != -1:
                                     extralines.append("\\strikeout default")
                                 document.body[elt:elt+1] = extralines + put_cmd_in_ert("\\end{cellvarwidth}") + ["\end_layout"]
-                                document.body[flt+1:flt+1] = put_cmd_in_ert("\\begin{cellvarwidth}" + alarg)
+                                parlang = -1
+                                for q in range(flt, elt):
+                                    if document.body[q] != "" and document.body[q][0] != "\\":
+                                        break
+                                    if document.body[q][:5] == "\\lang":
+                                        parlang = q
+                                        break
+                                if parlang != -1:
+                                    document.body[parlang+1:parlang+1] = put_cmd_in_ert("\\begin{cellvarwidth}" + alarg)
+                                else:
+                                    document.body[flt+1:flt+1] = put_cmd_in_ert("\\begin{cellvarwidth}" + alarg)
                                 needcellvarwidth = True
                                 needvarwidth = True
                         # ERT newlines and linebreaks (since LyX < 2.4 automatically inserts parboxes
@@ -4359,6 +4369,33 @@ def convert_vcolumns2(document):
                                  r'\usepackage{varwidth}'])
 
 
+frontispiece_def = [
+    r'### Inserted by lyx2lyx (frontispiece layout) ###',
+    r'Style Frontispiece',
+    r'  CopyStyle             Titlehead',
+    r'  LatexName             frontispiece',
+    r'End',
+]
+
+
+def convert_koma_frontispiece(document):
+    """Remove local KOMA frontispiece definition"""
+    if document.textclass[:3] != "scr":
+        return
+
+    if document.del_local_layout(frontispiece_def):
+        document.add_module("ruby")
+
+
+def revert_koma_frontispiece(document):
+    """Add local KOMA frontispiece definition"""
+    if document.textclass[:3] != "scr":
+        return
+
+    if find_token(document.body, "\\begin_layout Frontispiece", 0) != -1:
+        document.append_local_layout(frontispiece_def)
+
+
 ##
 # Conversion hub
 #
@@ -4425,10 +4462,12 @@ convert = [
            [602, [convert_branch_colors]],
            [603, []],
            [604, []],
-           [605, [convert_vcolumns2]]
+           [605, [convert_vcolumns2]],
+           [606, [convert_koma_frontispiece]]
           ]
 
-revert =  [[604, [revert_vcolumns2]],
+revert =  [[605, [revert_koma_frontispiece]],
+           [604, [revert_vcolumns2]],
            [603, [revert_branch_darkcols]],
            [602, [revert_darkmode_graphics]],
            [601, [revert_branch_colors]],