Skip to content

Commit 9c9f16c

Browse files
authored
Merge pull request #37 from drgrice1/no-default-auto-operators
Remove all of the default autoOperatorNames.
2 parents a1b3d63 + 8492310 commit 9c9f16c

File tree

5 files changed

+9
-41
lines changed

5 files changed

+9
-41
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@openwebwork/mathquill",
33
"description": "Easily type math in your webapp",
4-
"version": "0.11.0-beta.4",
4+
"version": "0.11.0-beta.5",
55
"license": "MPL-2.0",
66
"repository": {
77
"type": "git",

src/commands/math/basicSymbols.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Symbols for Basic Mathematics
22

3-
import { type Direction, noop, bindMixin, LatexCmds, CharCmds } from 'src/constants';
3+
import { type Direction, noop, bindMixin, LatexCmds, CharCmds, BuiltInOpNames } from 'src/constants';
44
import { Options } from 'src/options';
55
import type { Cursor } from 'src/cursor';
66
import { Parser } from 'services/parser.util';
@@ -40,10 +40,8 @@ class OperatorName extends Symbol {
4040
}
4141
}
4242

43-
for (const fn in new Options().autoOperatorNames) {
44-
if (fn !== '_maxLength') {
45-
LatexCmds[fn] = OperatorName;
46-
}
43+
for (const fn in BuiltInOpNames) {
44+
LatexCmds[fn] = OperatorName;
4745
}
4846

4947
LatexCmds.operatorname = class extends MathCommand {

src/options.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -129,39 +129,7 @@ export class Options {
129129
}
130130

131131
// The set of operator names that MathQuill auto-unitalicizes.
132-
static #autoOperatorNames: NamesWLength = (() => {
133-
const ops: NamesWLength = { _maxLength: 9 };
134-
135-
// Standard operators
136-
for (const op of [
137-
'arg',
138-
'det',
139-
'dim',
140-
'gcd',
141-
'hom',
142-
'ker',
143-
'lg',
144-
'lim',
145-
'max',
146-
'min',
147-
'sup',
148-
'limsup',
149-
'liminf',
150-
'injlim',
151-
'projlim',
152-
'Pr'
153-
]) {
154-
ops[op] = 1;
155-
}
156-
157-
// compat with some of the nonstandard LaTeX exported by MathQuill
158-
// before #247. None of these are real LaTeX commands so, seems safe
159-
for (const op of ['gcf', 'hcf', 'lcm', 'proj', 'span']) {
160-
ops[op] = 1;
161-
}
162-
163-
return ops;
164-
})();
132+
static #autoOperatorNames: NamesWLength = { _maxLength: 0 };
165133
#_autoOperatorNames?: NamesWLength;
166134
get autoOperatorNames(): NamesWLength {
167135
return this.#_autoOperatorNames ?? Options.#autoOperatorNames;

test/typing.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ suite('typing with auto-replaces', function () {
6565
});
6666

6767
test('auto-operator names', function () {
68+
mq.options.addAutoOperatorNames('ker');
6869
mq.typedText('\\ker^2');
6970
assertLatex('\\ker^2');
71+
mq.options.removeAutoOperatorNames('ker');
7072
});
7173

7274
test('nonexistent LaTeX command', function () {

0 commit comments

Comments
 (0)