]> git.lyx.org Git - features.git/commitdiff
Routine for adding modules to the list of modules. Preparatory for AMS modularization.
authorRichard Heck <rgheck@comcast.net>
Wed, 26 Dec 2007 20:15:31 +0000 (20:15 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 26 Dec 2007 20:15:31 +0000 (20:15 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22318 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_1_6.py

index edae58d70fe30521521addf749eeb16ae7f3ca9a..cf6ac5a454c6210a2149c2c6399fc1fc5870eccc 100644 (file)
@@ -36,6 +36,26 @@ def wrap_into_ert(string, src, dst):
     return string.replace(src, '\n\\begin_inset ERT\nstatus collapsed\n\\begin_layout Standard\n' 
       + dst + '\n\\end_layout\n\\end_inset\n')
 
+def add_module(module):
+  i = find_token(document.header, "\\begin_modules", 0)
+  if i == -1:
+    #No modules yet included
+    i = find_token(document.header, "\\textclass", 0)
+    if i == -1:
+      document.warning("Malformed LyX document: No \\textclass!!")
+      return
+    modinfo = ["\\begin_modules", module, "\\end_modules"]
+    document.header[i + 1: i + 1] = modinfo
+    return
+  j = find_token(document.header, "\\end_modules", i)
+  if j == -1:
+    document.warning("Malformed LyX document: No \\end_modules.")
+    return
+  k = find_token(document.header, module, i)
+  if k != -1 and k < j:
+    return
+  document.header.insert(i + 1, module)
+
 
 ####################################################################
 
@@ -921,7 +941,7 @@ def revert_slash(document):
         '\\begin_inset ERT\nstatus collapsed\n\n' \
         '\\begin_layout Standard\n\n\n\\backslash\n' \
         'slash{}\n\\end_layout\n\n\\end_inset\n\n')
-       
+
 
 def revert_nobreakdash(document):
     'Revert \\SpecialChar \\nobreakdash- to ERT'