Fix \dots to produce \ldots or \cdots depending on the following element (as the LaTeX version does)

This commit is contained in:
Davide P. Cervone 2012-01-18 09:40:12 -05:00
parent 682fe27d7e
commit 44344c7142
8 changed files with 29 additions and 9 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -317,7 +317,7 @@
var mml, c;
if (item.type === "open" || item.type === "left") {return true}
if (item.type === "mml" && item.data[0].type.match(/^(mo|mi|mtext)$/)) {
mml = item.data[0].CoreMO(), c = mml.data.join("");
mml = item.data[0], c = mml.data.join("");
if (c.length === 1 && !mml.movesupsub) {
c = STACKITEM.not.remap[c.charCodeAt(0)];
if (c) {mml.SetData(0,MML.chars(String.fromCharCode(c)))}
@ -344,6 +344,19 @@
0x22B4:0x22EC, 0x22B5:0x22ED, 0x2203:0x2204
};
STACKITEM.dots = STACKITEM.Subclass({
type: "dots",
checkItem: function (item) {
if (item.type === "open" || item.type === "left") {return true}
var dots = this.ldots;
if (item.type === "mml" && item.data[0].isEmbellished()) {
var tclass = item.data[0].CoreMO().Get("texClass");
if (tclass === MML.TEXCLASS.BIN || tclass === MML.TEXCLASS.REL) {dots = this.cdots}
}
return [dots,item];
}
});
var TEXDEF = {
//
@ -598,7 +611,6 @@
cdots: '22EF',
vdots: '22EE',
ddots: '22F1',
dots: '2026', // should be more complex than this
dotsc: '2026', // dots with commas
dotsb: '22EF', // dots with binary ops and relations
dotsm: '22EF', // dots with multiplication
@ -901,6 +913,7 @@
// Specially handled
not: 'Not',
dots: 'Dots',
space: 'Tilde',
@ -1481,6 +1494,13 @@
this.Push(STACKITEM.not());
},
Dots: function (name) {
this.Push(STACKITEM.dots().With({
ldots: this.mmlToken(MML.mo(MML.entity("#x2026"))),
cdots: this.mmlToken(MML.mo(MML.entity("#x22EF")))
}));
},
Require: function (name) {
var file = this.GetArgument(name)
.replace(/.*\//,"") // remove any leading path