mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Dummy format change for AMS modularization.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22470 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4aea2f6a73
commit
9f8bf4c9da
@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
|
||||
("1_3", [221], minor_versions("1.3" , 7)),
|
||||
("1_4", range(222,246), minor_versions("1.4" , 5)),
|
||||
("1_5", range(246,277), minor_versions("1.5" , 2)),
|
||||
("1_6", range(277,311), minor_versions("1.6" , 0))] # Bernhard Reiter: \nocite{*}
|
||||
("1_6", range(277,312), minor_versions("1.6" , 0))] # Richard Heck: AMS conversion
|
||||
|
||||
|
||||
def formats_list():
|
||||
@ -390,6 +390,28 @@ class LyX_base:
|
||||
self.header[i] = "\\textclass %s" % self.textclass
|
||||
|
||||
|
||||
#Note that the module will be added at the END of the extant ones
|
||||
def add_module(self, module):
|
||||
i = find_token(self.header, "\\begin_modules", 0)
|
||||
if i == -1:
|
||||
#No modules yet included
|
||||
i = find_token(self.header, "\\textclass", 0)
|
||||
if i == -1:
|
||||
self.warning("Malformed LyX document: No \\textclass!!")
|
||||
return
|
||||
modinfo = ["\\begin_modules", module, "\\end_modules"]
|
||||
self.header[i + 1: i + 1] = modinfo
|
||||
return
|
||||
j = find_token(self.header, "\\end_modules", i)
|
||||
if j == -1:
|
||||
self.warning("Malformed LyX document: No \\end_modules.")
|
||||
return
|
||||
k = find_token(self.header, module, i)
|
||||
if k != -1 and k < j:
|
||||
return
|
||||
self.header.insert(j, module)
|
||||
|
||||
|
||||
def set_parameter(self, param, value):
|
||||
" Set the value of the header parameter."
|
||||
i = find_token(self.header, '\\' + param, 0)
|
||||
|
@ -36,27 +36,6 @@ 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)
|
||||
|
||||
|
||||
####################################################################
|
||||
|
||||
def fix_wrong_tables(document):
|
||||
@ -633,6 +612,43 @@ def convert_url(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)'
|
||||
@ -1114,10 +1130,12 @@ convert = [[277, [fix_wrong_tables]],
|
||||
[307, []],
|
||||
[308, []],
|
||||
[309, []],
|
||||
[310, []]
|
||||
[310, []],
|
||||
[311, [convert_ams_classes]]
|
||||
]
|
||||
|
||||
revert = [[309, [revert_btprintall]],
|
||||
revert = [[310, []],
|
||||
[309, [revert_btprintall]],
|
||||
[308, [revert_nocite]],
|
||||
[307, [revert_serbianlatin]],
|
||||
[306, [revert_slash, revert_nobreakdash]],
|
||||
|
@ -118,7 +118,7 @@ namespace os = support::os;
|
||||
|
||||
namespace {
|
||||
|
||||
int const LYX_FORMAT = 310; // Bernhard Reiter: support for \nocite{*}
|
||||
int const LYX_FORMAT = 311; // Richard Heck: a dummy format to drive the AMS conversion
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user