Skip to content

Commit 9138604

Browse files
committed
Adds the enlose package.
1 parent f5c3f1f commit 9138604

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

lib/TeX-lab.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'mathjax3/input/tex/noundefined/NoUndefinedConfiguration.js';
1313
import 'mathjax3/input/tex/boldsymbol/BoldsymbolConfiguration.js';
1414
import 'mathjax3/input/tex/newcommand/NewcommandConfiguration.js';
1515
import 'mathjax3/input/tex/cancel/CancelConfiguration.js';
16+
import 'mathjax3/input/tex/enclose/EncloseConfiguration.js';
1617

1718

1819
let tex = new TeX();
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*************************************************************
2+
*
3+
* Copyright (c) 2018 The MathJax Consortium
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
19+
/**
20+
* @fileoverview Configuration file for the enclose package.
21+
*
22+
* @author [email protected] (Volker Sorge)
23+
*/
24+
25+
import {Configuration} from '../Configuration.js';
26+
import TexParser from '../TexParser.js';
27+
import {TexConstant} from '../TexConstants.js';
28+
import {CommandMap} from '../SymbolMap.js';
29+
import {ParseMethod} from '../Types.js';
30+
import ParseUtil from '../ParseUtil.js';
31+
32+
33+
/**
34+
* The attributes allowed in \enclose{notation}[attributes]{math}
35+
* @type {{[key: string]: number}}
36+
*/
37+
const ALLOWED: {[key: string]: number} = {
38+
arrow: 1,
39+
color: 1, mathcolor: 1,
40+
background: 1, mathbackground: 1,
41+
padding: 1,
42+
thickness: 1
43+
};
44+
45+
46+
// Namespace
47+
export let EncloseMethods: Record<string, ParseMethod> = {};
48+
49+
50+
/**
51+
* Implements \enclose{notation}[attr]{math}
52+
* (create <menclose notation="notation">math</menclose>)
53+
* @param {TexParser} parser The current tex parser.
54+
* @param {string} name The name of the calling macro.
55+
*/
56+
EncloseMethods.Enclose = function(parser: TexParser, name: string) {
57+
let notation = parser.GetArgument(name).replace(/,/g, ' ');
58+
const attr = parser.GetBrackets(name, '');
59+
const math = parser.ParseArg(name);
60+
const def = ParseUtil.splitPackageOptions(attr, ALLOWED);
61+
def.notation = notation;
62+
if (def.arrow) {
63+
def.notation += ' updiagonalarrow';
64+
delete def.arrow;
65+
}
66+
parser.Push(parser.create('node', 'menclose', [math], def));
67+
};
68+
69+
70+
new CommandMap('enclose', {enclose: 'Enclose'}, EncloseMethods);
71+
72+
73+
export const EncloseConfiguration = Configuration.create(
74+
'enclose', {handler: {macro: ['enclose']}}
75+
);
76+
77+

0 commit comments

Comments
 (0)