]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx_1_5.py
* doc/cs_Tutorial.lyx: update by Pavel Sanda
[lyx.git] / lib / lyx2lyx / lyx_1_5.py
index d7cc7cbef9bd849fdbc9fb7495a75bd7614c32f7..d4f00cfe3a30df2d593a5e3939db08437562ca61 100644 (file)
@@ -350,9 +350,6 @@ def convert_commandparams(document):
     # \begin_inset LatexCommand bibitem was not the official version (see
     # convert_bibitem()), but could be read in, so we convert it here, too.
 
-    # FIXME: Handle things like \command[foo[bar]]{foo{bar}}
-    # we need a real parser here.
-    regex = re.compile(r'\\([^\[\{]+)(\[[^\[\{]*\])?(\[[^\[\{]*\])?(\{[^}]*\})?')
     i = 0
     while 1:
         i = find_token(document.body, "\\begin_inset LatexCommand", i)
@@ -384,11 +381,11 @@ def convert_commandparams(document):
                 if nestdepth == 0:
                     state = "WS"
                 else:
-                    --nestdepth
+                    nestdepth = nestdepth - 1
             if ((state == "OPTION" and c == '[') or
                 (state == "SECOPTION" and c == '[') or
                 (state == "CONTENT" and c == '{')):
-                ++nestdepth
+                nestdepth = nestdepth + 1
             if state == "CMDNAME":
                     name += c
             elif state == "OPTION":
@@ -584,6 +581,29 @@ def revert_printnomenclature(document):
         document.preamble.append('\\makenomenclature')
 
 
+def convert_esint(document):
+    " Add \\use_esint setting to header. "
+    i = find_token(document.header, "\\cite_engine", 0)
+    if i == -1:
+        document.warning("Malformed LyX document: Missing `\\cite_engine'.")
+        return
+    # 0 is off, 1 is auto, 2 is on.
+    document.header.insert(i, '\\use_esint 0')
+
+
+def revert_esint(document):
+    " Remove \\use_esint setting from header. "
+    i = find_token(document.header, "\\use_esint", 0)
+    if i == -1:
+        document.warning("Malformed LyX document: Missing `\\use_esint'.")
+        return
+    use_esint = document.header[i].split()[1]
+    del document.header[i]
+    # 0 is off, 1 is auto, 2 is on.
+    if (use_esint == 2):
+        document.preamble.append('\\usepackage{esint}')
+
+
 ##
 # Conversion hub
 #
@@ -596,9 +616,11 @@ convert = [[246, []],
            [250, []],
            [251, []],
            [252, [convert_commandparams, convert_bibitem]],
-           [253, []]]
+           [253, []],
+           [254, [convert_esint]]]
 
-revert =  [[252, [revert_nomenclature, revert_printnomenclature]],
+revert =  [[253, [revert_esint]],
+           [252, [revert_nomenclature, revert_printnomenclature]],
            [251, [revert_commandparams]],
            [250, [revert_cs_label]],
            [249, []],