commit b75c718d57e9e97d119083c41b1f6d37c1e6350a
Author: Richard Heck <[email protected]>
Date:   Tue Dec 13 21:49:04 2016 -0500

    New format for changes to iopart.layout made at 91f980cf31.
---
 development/FORMAT     |    4 +++
 lib/lyx2lyx/lyx_2_3.py |   63 +++++++++++++++++++++++++++++++++++++++++++++++-
 src/version.h          |    4 +-
 3 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/development/FORMAT b/development/FORMAT
index 2a06d49..49acc05 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -11,6 +11,10 @@ adjustments are made to tex2lyx and bugs are fixed in 
lyx2lyx.
 
 -----------------------
 
+2016-12-13 Richard Heck <[email protected]>
+       * Format incremeneted to 518: iopart.layout now includes
+         stdlayouts.inc.
+
 2016-12-10 Jürgen Spitzmüller <[email protected]>
        * Format incremented to 517: InsetQuote now works in verbatim
          and Hebrew. On reversion, it is replaced by straight quotes
diff --git a/lib/lyx2lyx/lyx_2_3.py b/lib/lyx2lyx/lyx_2_3.py
index d3f3d40..c1f2844 100644
--- a/lib/lyx2lyx/lyx_2_3.py
+++ b/lib/lyx2lyx/lyx_2_3.py
@@ -586,6 +586,65 @@ def revert_quotes(document):
         i = l
     
 
+def revert_iopart(document):
+    " Input new styles via local layout "
+    if document.textclass != "iopart":
+        return
+
+    i = find_token(document.header, "\\begin_local_layout", 0)
+    if i == -1:
+        k = find_token(document.header, "\\language", 0)
+        if k == -1:
+            # this should not happen
+            document.warning("Malformed LyX document! No \\language header 
found!")
+            return
+        document.header[k-1 : k-1] = ["\\begin_local_layout", 
"\\end_local_layout"]
+        i = k-1
+
+    j = find_end_of(document.header, i, "\\begin_local_layout", 
"\\end_local_layout")
+    if j == -1:
+        # this should not happen
+        document.warning("Malformed LyX document! Can't find end of local 
layout!")
+        return
+
+    document.header[i+1 : i+1] = [
+        "### Inserted by lyx2lyx (stdlayouts) ###",
+        "Input stdlayouts.inc",
+        "### End of insertion by lyx2lyx (stdlayouts) ###"
+    ]
+    return
+
+
+def convert_iopart(document):
+    " Remove local layout we added, if it is there "
+    if document.textclass != "iopart":
+        return
+
+    i = find_token(document.header, "\\begin_local_layout", 0)
+    if i == -1:
+        return
+
+    j = find_end_of(document.header, i, "\\begin_local_layout", 
"\\end_local_layout")
+    if j == -1:
+        # this should not happen
+        document.warning("Malformed LyX document! Can't find end of local 
layout!")
+        return
+
+    k = find_token(document.header, "### Inserted by lyx2lyx (stdlayouts) 
###", i, j)
+    if k != -1:
+        l = find_token(document.header, "### End of insertion by lyx2lyx 
(stdlayouts) ###", i, j)
+        if l == -1:
+            # this should not happen
+            document.warning("End of lyx2lyx local layout insertion not 
found!")
+            return
+        if k == i + 1 and l == j - 1:
+            # that was all the local layout there was
+            document.header[i : j + 1] = []
+        else:
+            document.header[k : l + 1] = []
+
+    return
+
 
 ##
 # Conversion hub
@@ -601,10 +660,12 @@ convert = [
            [514, []],
            [515, []],
            [516, [convert_inputenc]],
-           [517, []]  
+           [517, []],
+           [518, [convert_iopart]]
           ]
 
 revert =  [
+           [517, [revert_iopart]],
            [516, [revert_quotes]],
            [515, []],
            [514, [revert_urdu, revert_syriac]],
diff --git a/src/version.h b/src/version.h
index 5e67fa9..15fb8ee 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 517 // spitz: quote inset in verbatim
-#define LYX_FORMAT_TEX2LYX 517
+#define LYX_FORMAT_LYX 518 // rgheck: changes to iopart.layout
+#define LYX_FORMAT_TEX2LYX 518
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER

Reply via email to