return string.replace(src, '\n\\begin_inset ERT\nstatus collapsed\n\\begin_layout Standard\n'
+ dst + '\n\\end_layout\n\\end_inset\n')
-
####################################################################
def fix_wrong_tables(document):
document.body[i:k] = newstuff
i = k
+def convert_ams_classes(document):
+ tc = document.textclass
+ if (tc != "amsart" and tc != "amsart-plain" and
+ tc != "amsart-seq" and tc != "amsbook"):
+ return
+ if tc == "amsart-plain":
+ document.textclass = "amsart"
+ document.set_textclass()
+ document.add_module("Theorems (Starred)")
+ return
+ if tc == "amsart-seq":
+ document.textclass = "amsart"
+ document.set_textclass()
+ document.add_module("Theorems (AMS)")
+
+ #Now we want to see if any of the environments in the extended theorems
+ #module were used in this document. If so, we'll add that module, too.
+ layouts = ["Criterion", "Algorithm", "Axiom", "Condition", "Note", \
+ "Notation", "Summary", "Acknowledgement", "Conclusion", "Fact", \
+ "Assumption"]
+
+ r = re.compile(r'^\\begin_layout (.*?)\*?\s*$')
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_layout", i)
+ if i == -1:
+ return
+ m = r.match(document.body[i])
+ if m == None:
+ document.warning("Weirdly formed \\begin_layout at line " + i + " of body!")
+ i += 1
+ continue
+ m = m.group(1)
+ if layouts.count(m) != 0:
+ document.add_module("Theorems (AMS-Extended)")
+ return
+ i += 1
def revert_href(document):
'Reverts hyperlink insets (href) to url insets (url)'
'\\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'
i = j
+def revert_btprintall(document):
+ "Revert (non-bibtopic) btPrintAll option to ERT \nocite{*}"
+ i = find_token(document.header, '\\use_bibtopic', 0)
+ if i == -1:
+ document.warning("Malformed lyx document: Missing '\\use_bibtopic'.")
+ return
+ if get_value(document.header, '\\use_bibtopic', 0) == "false":
+ i = 0
+ while i < len(document.body):
+ i = find_token(document.body, "\\begin_inset CommandInset bibtex", i)
+ if i == -1:
+ return
+ j = find_end_of_inset(document.body, i + 1)
+ if j == -1:
+ #this should not happen
+ document.warning("End of CommandInset bibtex not found in revert_btprintall!")
+ j = len(document.body)
+ for k in range(i, j):
+ if (document.body[k] == 'btprint "btPrintAll"'):
+ del document.body[k]
+ document.body.insert(i, "\\begin_inset ERT\n" \
+ "status collapsed\n\n\\begin_layout Standard\n\n" \
+ "\\backslash\nnocite{*}\n" \
+ "\\end_layout\n\\end_inset\n")
+ i = j
+
+
def revert_bahasam(document):
"Set language Bahasa Malaysia to Bahasa Indonesia"
i = 0
[306, []],
[307, []],
[308, []],
- [309, []]
+ [309, []],
+ [310, []],
+ [311, [convert_ams_classes]]
]
-revert = [[308, [revert_nocite]],
+revert = [[310, []],
+ [309, [revert_btprintall]],
+ [308, [revert_nocite]],
[307, [revert_serbianlatin]],
[306, [revert_slash, revert_nobreakdash]],
[305, [revert_interlingua]],