katex 0.13.13 → 0.13.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +32 -5
- package/contrib/auto-render/test/auto-render-spec.js +3 -0
- package/contrib/copy-tex/README.md +3 -3
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +32 -5
- package/dist/contrib/auto-render.mjs +1 -1
- package/dist/contrib/render-a11y-string.mjs +1 -1
- package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/katex.css +1 -1
- package/dist/katex.js +2356 -2275
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +2512 -2434
- package/katex.js +1 -1
- package/package.json +22 -18
- package/src/MacroExpander.js +11 -3
- package/src/Namespace.js +10 -0
- package/src/Parser.js +17 -9
- package/src/Settings.js +1 -1
- package/src/defineMacro.js +118 -0
- package/src/fontMetrics.js +0 -2
- package/src/fontMetricsData.js +7 -7
- package/src/fonts/Makefile +4 -4
- package/src/fonts/default.cfg +1 -1
- package/src/fonts/generate_fonts.py +3 -3
- package/src/functions/accent.js +11 -4
- package/src/functions/char.js +13 -2
- package/src/functions/operatorname.js +1 -1
- package/src/macros.js +5 -112
- package/src/metrics/README.md +1 -1
- package/src/metrics/extract_tfms.py +3 -3
- package/src/metrics/extract_ttfs.py +2 -2
- package/src/metrics/format_json.py +1 -1
- package/src/symbols.js +4 -3
- package/src/unicodeAccents.js +1 -0
package/katex.js
CHANGED
|
@@ -28,7 +28,7 @@ import type {AnyParseNode} from "./src/parseNode";
|
|
|
28
28
|
import type {DomSpan} from "./src/domTree";
|
|
29
29
|
|
|
30
30
|
import {defineSymbol} from './src/symbols';
|
|
31
|
-
import
|
|
31
|
+
import defineMacro from './src/defineMacro';
|
|
32
32
|
import {setFontMetrics} from './src/fontMetrics';
|
|
33
33
|
|
|
34
34
|
declare var __VERSION__: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "katex",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.18",
|
|
4
4
|
"description": "Fast math typesetting for the web.",
|
|
5
5
|
"main": "dist/katex.js",
|
|
6
6
|
"homepage": "https://katex.org",
|
|
@@ -16,20 +16,22 @@
|
|
|
16
16
|
"dist/"
|
|
17
17
|
],
|
|
18
18
|
"license": "MIT",
|
|
19
|
+
"packageManager": "yarn@3.0.1",
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@babel/core": "^7.10.4",
|
|
22
|
+
"@babel/eslint-parser": "^7.15.0",
|
|
21
23
|
"@babel/plugin-proposal-class-properties": "^7.10.4",
|
|
22
24
|
"@babel/plugin-transform-runtime": "^7.10.4",
|
|
23
25
|
"@babel/preset-env": "^7.10.4",
|
|
24
26
|
"@babel/preset-flow": "^7.10.4",
|
|
27
|
+
"@babel/preset-react": "^7.14.5",
|
|
25
28
|
"@babel/register": "^7.10.4",
|
|
26
29
|
"@babel/runtime": "^7.10.4",
|
|
27
30
|
"@rollup/plugin-alias": "^3.1.1",
|
|
28
31
|
"@rollup/plugin-babel": "^5.0.4",
|
|
29
32
|
"@semantic-release/changelog": "^5.0.1",
|
|
30
33
|
"@semantic-release/git": "^9.0.0",
|
|
31
|
-
"babel-
|
|
32
|
-
"babel-jest": "^26.1.0",
|
|
34
|
+
"babel-jest": "^27.0.0",
|
|
33
35
|
"babel-loader": "^8.0.5",
|
|
34
36
|
"babel-plugin-istanbul": "^6.0.0",
|
|
35
37
|
"babel-plugin-preval": "^5.0.0",
|
|
@@ -38,13 +40,12 @@
|
|
|
38
40
|
"browserslist": "^4.13.0",
|
|
39
41
|
"browserstack-local": "^1.4.5",
|
|
40
42
|
"caniuse-lite": "^1.0.30001102",
|
|
41
|
-
"css-loader": "^
|
|
43
|
+
"css-loader": "^6.0.0",
|
|
42
44
|
"cssnano": "^5.0.0-rc.1",
|
|
43
45
|
"eslint": "^7.4.0",
|
|
44
46
|
"eslint-plugin-actions": "^1.0.1",
|
|
45
47
|
"eslint-plugin-flowtype": "^5.2.0",
|
|
46
48
|
"eslint-plugin-react": "^7.20.3",
|
|
47
|
-
"file-loader": "^6.0.0",
|
|
48
49
|
"flow-bin": "^0.135.0",
|
|
49
50
|
"fs-extra": "^10.0.0",
|
|
50
51
|
"got": "^11.8.0",
|
|
@@ -52,37 +53,38 @@
|
|
|
52
53
|
"istanbul-lib-coverage": "^3.0.0",
|
|
53
54
|
"istanbul-lib-report": "^3.0.0",
|
|
54
55
|
"istanbul-reports": "^3.0.2",
|
|
55
|
-
"jest": "^
|
|
56
|
-
"jest-diff": "^
|
|
57
|
-
"jest-matcher-utils": "^
|
|
58
|
-
"jest-message-util": "^
|
|
56
|
+
"jest": "^27.0.0",
|
|
57
|
+
"jest-diff": "^27.0.0",
|
|
58
|
+
"jest-matcher-utils": "^27.0.0",
|
|
59
|
+
"jest-message-util": "^27.0.0",
|
|
59
60
|
"jest-serializer-html": "^7.0.0",
|
|
60
61
|
"js-yaml": "^4.0.0",
|
|
61
62
|
"json-stable-stringify": "^1.0.1",
|
|
62
63
|
"jspngopt": "^0.2.0",
|
|
63
64
|
"less": "^4.0.0",
|
|
64
|
-
"less-loader": "^
|
|
65
|
-
"mini-css-extract-plugin": "^
|
|
65
|
+
"less-loader": "^10.0.0",
|
|
66
|
+
"mini-css-extract-plugin": "^2.0.0",
|
|
66
67
|
"mkdirp": "^1.0.4",
|
|
68
|
+
"p-retry": "^4.6.1",
|
|
67
69
|
"pako": "^2.0.0",
|
|
68
70
|
"postcss": "^8.0.0",
|
|
69
|
-
"postcss-loader": "^
|
|
71
|
+
"postcss-loader": "^6.0.0",
|
|
70
72
|
"postcss-preset-env": "^6.7.0",
|
|
71
73
|
"prettier": "^2.0.5",
|
|
72
74
|
"query-string": "^7.0.0",
|
|
73
75
|
"rimraf": "^3.0.2",
|
|
74
76
|
"rollup": "^2.21.0",
|
|
75
|
-
"selenium-webdriver": "^
|
|
77
|
+
"selenium-webdriver": "^4.0.0-beta.4",
|
|
76
78
|
"semantic-release": "^17.4.1",
|
|
77
79
|
"sri-toolbox": "^0.2.0",
|
|
78
|
-
"style-loader": "^
|
|
80
|
+
"style-loader": "^3.0.0",
|
|
79
81
|
"stylelint": "^13.6.1",
|
|
80
82
|
"stylelint-config-standard": "^22.0.0",
|
|
81
83
|
"terser-webpack-plugin": "^5.0.3",
|
|
82
|
-
"webpack": "^5.
|
|
84
|
+
"webpack": "^5.51.1",
|
|
83
85
|
"webpack-bundle-analyzer": "^4.0.0",
|
|
84
|
-
"webpack-cli": "^4.
|
|
85
|
-
"webpack-dev-server": "^4.0.0
|
|
86
|
+
"webpack-cli": "^4.8.0",
|
|
87
|
+
"webpack-dev-server": "^4.0.0"
|
|
86
88
|
},
|
|
87
89
|
"bin": "cli.js",
|
|
88
90
|
"scripts": {
|
|
@@ -102,7 +104,9 @@
|
|
|
102
104
|
"clean-install": "yarn clean && yarn",
|
|
103
105
|
"start": "webpack serve --config webpack.dev.js",
|
|
104
106
|
"analyze": "webpack --config webpack.analyze.js",
|
|
105
|
-
"build": "rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c && webpack && node update-sri.js package dist/README.md",
|
|
107
|
+
"build": "rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c --failAfterWarnings && webpack && node update-sri.js package dist/README.md",
|
|
108
|
+
"build:fonts": "dockers/fonts/buildFonts.sh",
|
|
109
|
+
"build:metrics": "dockers/fonts/buildMetrics.sh",
|
|
106
110
|
"watch": "yarn build --watch",
|
|
107
111
|
"postversion": "yarn dist && node update-sri.js package README.md contrib/*/README.md docs/*.md website/pages/index.html",
|
|
108
112
|
"semantic-release": "semantic-release",
|
package/src/MacroExpander.js
CHANGED
|
@@ -11,10 +11,10 @@ import {Token} from "./Token";
|
|
|
11
11
|
import type {Mode} from "./types";
|
|
12
12
|
import ParseError from "./ParseError";
|
|
13
13
|
import Namespace from "./Namespace";
|
|
14
|
-
import
|
|
14
|
+
import macros from "./macros";
|
|
15
15
|
|
|
16
16
|
import type {MacroContextInterface, MacroDefinition, MacroExpansion, MacroArg}
|
|
17
|
-
from "./
|
|
17
|
+
from "./defineMacro";
|
|
18
18
|
import type Settings from "./Settings";
|
|
19
19
|
|
|
20
20
|
// List of commands that act like macros but aren't defined as a macro,
|
|
@@ -40,7 +40,7 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
40
40
|
this.expansionCount = 0;
|
|
41
41
|
this.feed(input);
|
|
42
42
|
// Make new global namespace
|
|
43
|
-
this.macros = new Namespace(
|
|
43
|
+
this.macros = new Namespace(macros, settings.macros);
|
|
44
44
|
this.mode = mode;
|
|
45
45
|
this.stack = []; // contains tokens in REVERSE order
|
|
46
46
|
}
|
|
@@ -74,6 +74,14 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
74
74
|
this.macros.endGroup();
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Ends all currently nested groups (if any), restoring values before the
|
|
79
|
+
* groups began. Useful in case of an error in the middle of parsing.
|
|
80
|
+
*/
|
|
81
|
+
endGroups() {
|
|
82
|
+
this.macros.endGroups();
|
|
83
|
+
}
|
|
84
|
+
|
|
77
85
|
/**
|
|
78
86
|
* Returns the topmost token on the stack, without expanding it.
|
|
79
87
|
* Similar in behavior to TeX's `\futurelet`.
|
package/src/Namespace.js
CHANGED
|
@@ -57,6 +57,16 @@ export default class Namespace<Value> {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Ends all currently nested groups (if any), restoring values before the
|
|
62
|
+
* groups began. Useful in case of an error in the middle of parsing.
|
|
63
|
+
*/
|
|
64
|
+
endGroups() {
|
|
65
|
+
while (this.undefStack.length > 0) {
|
|
66
|
+
this.endGroup();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
60
70
|
/**
|
|
61
71
|
* Detect whether `name` has a definition. Equivalent to
|
|
62
72
|
* `get(name) != null`.
|
package/src/Parser.js
CHANGED
|
@@ -130,17 +130,24 @@ export default class Parser {
|
|
|
130
130
|
this.gullet.macros.set("\\color", "\\textcolor");
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
try {
|
|
134
|
+
// Try to parse the input
|
|
135
|
+
const parse = this.parseExpression(false);
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
// If we succeeded, make sure there's an EOF at the end
|
|
138
|
+
this.expect("EOF");
|
|
138
139
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
// End the group namespace for the expression
|
|
141
|
+
if (!this.settings.globalGroup) {
|
|
142
|
+
this.gullet.endGroup();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return parse;
|
|
146
|
+
|
|
147
|
+
// Close any leftover groups in case of a parse error.
|
|
148
|
+
} finally {
|
|
149
|
+
this.gullet.endGroups();
|
|
142
150
|
}
|
|
143
|
-
return parse;
|
|
144
151
|
}
|
|
145
152
|
|
|
146
153
|
static endOfExpression: string[] = ["}", "\\endgroup", "\\end", "\\right", "&"];
|
|
@@ -951,7 +958,8 @@ export default class Parser {
|
|
|
951
958
|
if (!unicodeAccents[accent]) {
|
|
952
959
|
throw new ParseError(`Unknown accent ' ${accent}'`, nucleus);
|
|
953
960
|
}
|
|
954
|
-
const command = unicodeAccents[accent][this.mode]
|
|
961
|
+
const command = unicodeAccents[accent][this.mode] ||
|
|
962
|
+
unicodeAccents[accent].text;
|
|
955
963
|
if (!command) {
|
|
956
964
|
throw new ParseError(
|
|
957
965
|
`Accent ${accent} unsupported in ${this.mode} mode`,
|
package/src/Settings.js
CHANGED
|
@@ -10,7 +10,7 @@ import ParseError from "./ParseError";
|
|
|
10
10
|
import {Token} from "./Token";
|
|
11
11
|
|
|
12
12
|
import type {AnyParseNode} from "./parseNode";
|
|
13
|
-
import type {MacroMap} from "./
|
|
13
|
+
import type {MacroMap} from "./defineMacro";
|
|
14
14
|
|
|
15
15
|
export type StrictFunction =
|
|
16
16
|
(errorCode: string, errorMsg: string, token?: Token | AnyParseNode) =>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import {Token} from "./Token";
|
|
4
|
+
import type Namespace from "./Namespace";
|
|
5
|
+
import type {Mode} from "./types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Provides context to macros defined by functions. Implemented by
|
|
9
|
+
* MacroExpander.
|
|
10
|
+
*/
|
|
11
|
+
export interface MacroContextInterface {
|
|
12
|
+
mode: Mode;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Object mapping macros to their expansions.
|
|
16
|
+
*/
|
|
17
|
+
macros: Namespace<MacroDefinition>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns the topmost token on the stack, without expanding it.
|
|
21
|
+
* Similar in behavior to TeX's `\futurelet`.
|
|
22
|
+
*/
|
|
23
|
+
future(): Token;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Remove and return the next unexpanded token.
|
|
27
|
+
*/
|
|
28
|
+
popToken(): Token;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Consume all following space tokens, without expansion.
|
|
32
|
+
*/
|
|
33
|
+
consumeSpaces(): void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Expand the next token only once if possible.
|
|
37
|
+
*/
|
|
38
|
+
expandOnce(expandableOnly?: boolean): Token | Token[];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Expand the next token only once (if possible), and return the resulting
|
|
42
|
+
* top token on the stack (without removing anything from the stack).
|
|
43
|
+
* Similar in behavior to TeX's `\expandafter\futurelet`.
|
|
44
|
+
*/
|
|
45
|
+
expandAfterFuture(): Token;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Recursively expand first token, then return first non-expandable token.
|
|
49
|
+
*/
|
|
50
|
+
expandNextToken(): Token;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Fully expand the given macro name and return the resulting list of
|
|
54
|
+
* tokens, or return `undefined` if no such macro is defined.
|
|
55
|
+
*/
|
|
56
|
+
expandMacro(name: string): Token[] | void;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Fully expand the given macro name and return the result as a string,
|
|
60
|
+
* or return `undefined` if no such macro is defined.
|
|
61
|
+
*/
|
|
62
|
+
expandMacroAsText(name: string): string | void;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Consume an argument from the token stream, and return the resulting array
|
|
66
|
+
* of tokens and start/end token.
|
|
67
|
+
*/
|
|
68
|
+
consumeArg(delims?: ?string[]): MacroArg;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Consume the specified number of arguments from the token stream,
|
|
72
|
+
* and return the resulting array of arguments.
|
|
73
|
+
*/
|
|
74
|
+
consumeArgs(numArgs: number): Token[][];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Determine whether a command is currently "defined" (has some
|
|
78
|
+
* functionality), meaning that it's a macro (in the current group),
|
|
79
|
+
* a function, a symbol, or one of the special commands listed in
|
|
80
|
+
* `implicitCommands`.
|
|
81
|
+
*/
|
|
82
|
+
isDefined(name: string): boolean;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Determine whether a command is expandable.
|
|
86
|
+
*/
|
|
87
|
+
isExpandable(name: string): boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type MacroArg = {
|
|
91
|
+
tokens: Token[],
|
|
92
|
+
start: Token,
|
|
93
|
+
end: Token
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/** Macro tokens (in reverse order). */
|
|
97
|
+
export type MacroExpansion = {
|
|
98
|
+
tokens: Token[],
|
|
99
|
+
numArgs: number,
|
|
100
|
+
delimiters?: string[][],
|
|
101
|
+
unexpandable?: boolean, // used in \let
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type MacroDefinition = string | MacroExpansion |
|
|
105
|
+
(MacroContextInterface => (string | MacroExpansion));
|
|
106
|
+
export type MacroMap = {[string]: MacroDefinition};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* All registered global/built-in macros.
|
|
110
|
+
* `macros.js` exports this same dictionary again and makes it public.
|
|
111
|
+
* `Parser.js` requires this dictionary via `macros.js`.
|
|
112
|
+
*/
|
|
113
|
+
export const _macros: MacroMap = {};
|
|
114
|
+
|
|
115
|
+
// This function might one day accept an additional argument and do more things.
|
|
116
|
+
export default function defineMacro(name: string, body: MacroDefinition) {
|
|
117
|
+
_macros[name] = body;
|
|
118
|
+
}
|
package/src/fontMetrics.js
CHANGED
package/src/fontMetricsData.js
CHANGED
|
@@ -1038,7 +1038,7 @@ export default {
|
|
|
1038
1038
|
"8221": [0, 0.69444, 0, 0, 0.5],
|
|
1039
1039
|
"8224": [0.19444, 0.69444, 0, 0, 0.44445],
|
|
1040
1040
|
"8225": [0.19444, 0.69444, 0, 0, 0.44445],
|
|
1041
|
-
"8230": [0, 0.
|
|
1041
|
+
"8230": [0, 0.123, 0, 0, 1.172],
|
|
1042
1042
|
"8242": [0, 0.55556, 0, 0, 0.275],
|
|
1043
1043
|
"8407": [0, 0.71444, 0.15382, 0, 0.5],
|
|
1044
1044
|
"8463": [0, 0.68889, 0, 0, 0.54028],
|
|
@@ -1102,7 +1102,7 @@ export default {
|
|
|
1102
1102
|
"8773": [-0.022, 0.589, 0, 0, 1.0],
|
|
1103
1103
|
"8776": [-0.01688, 0.48312, 0, 0, 0.77778],
|
|
1104
1104
|
"8781": [-0.03625, 0.46375, 0, 0, 0.77778],
|
|
1105
|
-
"8784": [-0.133, 0.
|
|
1105
|
+
"8784": [-0.133, 0.673, 0, 0, 0.778],
|
|
1106
1106
|
"8801": [-0.03625, 0.46375, 0, 0, 0.77778],
|
|
1107
1107
|
"8804": [0.13597, 0.63597, 0, 0, 0.77778],
|
|
1108
1108
|
"8805": [0.13597, 0.63597, 0, 0, 0.77778],
|
|
@@ -1133,9 +1133,9 @@ export default {
|
|
|
1133
1133
|
"8901": [-0.05555, 0.44445, 0, 0, 0.27778],
|
|
1134
1134
|
"8902": [-0.03472, 0.46528, 0, 0, 0.5],
|
|
1135
1135
|
"8904": [0.005, 0.505, 0, 0, 0.9],
|
|
1136
|
-
"8942": [0.03, 0.
|
|
1137
|
-
"8943": [-0.19, 0.
|
|
1138
|
-
"8945": [-0.1, 0.
|
|
1136
|
+
"8942": [0.03, 0.903, 0, 0, 0.278],
|
|
1137
|
+
"8943": [-0.19, 0.313, 0, 0, 1.172],
|
|
1138
|
+
"8945": [-0.1, 0.823, 0, 0, 1.282],
|
|
1139
1139
|
"8968": [0.25, 0.75, 0, 0, 0.44445],
|
|
1140
1140
|
"8969": [0.25, 0.75, 0, 0, 0.44445],
|
|
1141
1141
|
"8970": [0.25, 0.75, 0, 0, 0.44445],
|
|
@@ -1143,7 +1143,7 @@ export default {
|
|
|
1143
1143
|
"8994": [-0.14236, 0.35764, 0, 0, 1.0],
|
|
1144
1144
|
"8995": [-0.14236, 0.35764, 0, 0, 1.0],
|
|
1145
1145
|
"9136": [0.244, 0.744, 0, 0, 0.412],
|
|
1146
|
-
"9137": [0.244, 0.
|
|
1146
|
+
"9137": [0.244, 0.745, 0, 0, 0.412],
|
|
1147
1147
|
"9651": [0.19444, 0.69444, 0, 0, 0.88889],
|
|
1148
1148
|
"9657": [-0.03472, 0.46528, 0, 0, 0.5],
|
|
1149
1149
|
"9661": [0.19444, 0.69444, 0, 0, 0.88889],
|
|
@@ -1159,7 +1159,7 @@ export default {
|
|
|
1159
1159
|
"10216": [0.25, 0.75, 0, 0, 0.38889],
|
|
1160
1160
|
"10217": [0.25, 0.75, 0, 0, 0.38889],
|
|
1161
1161
|
"10222": [0.244, 0.744, 0, 0, 0.412],
|
|
1162
|
-
"10223": [0.244, 0.
|
|
1162
|
+
"10223": [0.244, 0.745, 0, 0, 0.412],
|
|
1163
1163
|
"10229": [0.011, 0.511, 0, 0, 1.609],
|
|
1164
1164
|
"10230": [0.011, 0.511, 0, 0, 1.638],
|
|
1165
1165
|
"10231": [0.011, 0.511, 0, 0, 1.859],
|
package/src/fonts/Makefile
CHANGED
|
@@ -42,7 +42,7 @@ config: $(CUSTOM).pl
|
|
|
42
42
|
|
|
43
43
|
blacker: $(MFTRACE_MODIFIED)
|
|
44
44
|
$(MFTRACE_MODIFIED):
|
|
45
|
-
$(PERL) makeBlacker 15 # values between 10 and 30 seem best
|
|
45
|
+
$(PERL) -I. makeBlacker 15 # values between 10 and 30 seem best
|
|
46
46
|
|
|
47
47
|
pfa: $(MFTRACE_MODIFIED)
|
|
48
48
|
@echo "cmr10"
|
|
@@ -109,7 +109,7 @@ pfa: $(MFTRACE_MODIFIED)
|
|
|
109
109
|
ff: pfa
|
|
110
110
|
mkdir -p ff otf
|
|
111
111
|
rm -f ff/* otf/*
|
|
112
|
-
$(PERL) makeFF
|
|
112
|
+
$(PERL) -I. makeFF
|
|
113
113
|
|
|
114
114
|
.PHONY: fonts
|
|
115
115
|
fonts: ff
|
|
@@ -123,9 +123,9 @@ fonts: ff
|
|
|
123
123
|
\
|
|
124
124
|
echo "Hinting $$file"; \
|
|
125
125
|
if echo "$$file" | $(GREP) -q -e "Size[1-4]" -e "Typewriter"; then \
|
|
126
|
-
$(TTFAUTOHINT) --windows-compatibility --symbol ttf/$$file.ttf ttf/$$file.ttf.hinted; \
|
|
126
|
+
$(TTFAUTOHINT) -f none -S --windows-compatibility --symbol ttf/$$file.ttf ttf/$$file.ttf.hinted; \
|
|
127
127
|
else \
|
|
128
|
-
$(TTFAUTOHINT) --windows-compatibility ttf/$$file.ttf ttf/$$file.ttf.hinted; \
|
|
128
|
+
$(TTFAUTOHINT) -f none -S --windows-compatibility ttf/$$file.ttf ttf/$$file.ttf.hinted; \
|
|
129
129
|
fi; \
|
|
130
130
|
mv ttf/$$file.ttf.hinted ttf/$$file.ttf; \
|
|
131
131
|
\
|
package/src/fonts/default.cfg
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
2
|
|
|
3
3
|
import sys
|
|
4
4
|
import os
|
|
@@ -9,7 +9,7 @@ from fontTools.misc.timeTools import timestampNow
|
|
|
9
9
|
sfnt.USE_ZOPFLI = True
|
|
10
10
|
|
|
11
11
|
if len(sys.argv) < 2:
|
|
12
|
-
print
|
|
12
|
+
print("Usage: %s <font file>" % sys.argv[0])
|
|
13
13
|
sys.exit(1)
|
|
14
14
|
|
|
15
15
|
font_file = sys.argv[1]
|
|
@@ -36,7 +36,7 @@ if 'GDEF' in font:
|
|
|
36
36
|
font['name'].names = [record for record in font['name'].names if record.platformID != 1]
|
|
37
37
|
font['cmap'].tables = [table for table in font['cmap'].tables if table.platformID != 1]
|
|
38
38
|
|
|
39
|
-
font['name'].setName(
|
|
39
|
+
font['name'].setName('Version ' + str(timestamp), 5, 3, 1, 1033)
|
|
40
40
|
|
|
41
41
|
# fix OS/2 and hhea metrics
|
|
42
42
|
glyf = font['glyf']
|
package/src/functions/accent.js
CHANGED
|
@@ -74,10 +74,14 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
74
74
|
// TODO(emily): Find a better way to get the skew
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
const accentBelow = group.label === "\\c";
|
|
78
|
+
|
|
77
79
|
// calculate the amount of space between the body and the accent
|
|
78
|
-
let clearance =
|
|
79
|
-
body.height
|
|
80
|
-
|
|
80
|
+
let clearance = accentBelow
|
|
81
|
+
? body.height + body.depth
|
|
82
|
+
: Math.min(
|
|
83
|
+
body.height,
|
|
84
|
+
options.fontMetrics().xHeight);
|
|
81
85
|
|
|
82
86
|
// Build the accent
|
|
83
87
|
let accentBody;
|
|
@@ -100,6 +104,9 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
100
104
|
// shift the accent over to a place we don't want.
|
|
101
105
|
accent.italic = 0;
|
|
102
106
|
width = accent.width;
|
|
107
|
+
if (accentBelow) {
|
|
108
|
+
clearance += accent.depth;
|
|
109
|
+
}
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
accentBody = buildCommon.makeSpan(["accent-body"], [accent]);
|
|
@@ -244,7 +251,7 @@ defineFunction({
|
|
|
244
251
|
type: "accent",
|
|
245
252
|
names: [
|
|
246
253
|
"\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"',
|
|
247
|
-
"\\r", "\\H", "\\v", "\\textcircled",
|
|
254
|
+
"\\c", "\\r", "\\H", "\\v", "\\textcircled",
|
|
248
255
|
],
|
|
249
256
|
props: {
|
|
250
257
|
numArgs: 1,
|
package/src/functions/char.js
CHANGED
|
@@ -21,14 +21,25 @@ defineFunction({
|
|
|
21
21
|
const node = assertNodeType(group[i], "textord");
|
|
22
22
|
number += node.text;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
let code = parseInt(number);
|
|
25
|
+
let text;
|
|
25
26
|
if (isNaN(code)) {
|
|
26
27
|
throw new ParseError(`\\@char has non-numeric argument ${number}`);
|
|
28
|
+
// If we drop IE support, the following code could be replaced with
|
|
29
|
+
// text = String.fromCodePoint(code)
|
|
30
|
+
} else if (code < 0 || code >= 0x10ffff) {
|
|
31
|
+
throw new ParseError(`\\@char with invalid code point ${number}`);
|
|
32
|
+
} else if (code <= 0xffff) {
|
|
33
|
+
text = String.fromCharCode(code);
|
|
34
|
+
} else { // Astral code point; split into surrogate halves
|
|
35
|
+
code -= 0x10000;
|
|
36
|
+
text = String.fromCharCode((code >> 10) + 0xd800,
|
|
37
|
+
(code & 0x3ff) + 0xdc00);
|
|
27
38
|
}
|
|
28
39
|
return {
|
|
29
40
|
type: "textord",
|
|
30
41
|
mode: parser.mode,
|
|
31
|
-
text:
|
|
42
|
+
text: text,
|
|
32
43
|
};
|
|
33
44
|
},
|
|
34
45
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction, {ordargument} from "../defineFunction";
|
|
3
|
-
import
|
|
3
|
+
import defineMacro from "../defineMacro";
|
|
4
4
|
import buildCommon from "../buildCommon";
|
|
5
5
|
import mathMLTree from "../mathMLTree";
|
|
6
6
|
import {SymbolNode} from "../domTree";
|
package/src/macros.js
CHANGED
|
@@ -4,124 +4,17 @@
|
|
|
4
4
|
* This can be used to define some commands in terms of others.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
// Export global macros object from defineMacro
|
|
8
|
+
import defineMacro, {_macros} from "./defineMacro";
|
|
9
|
+
const macros = _macros;
|
|
10
|
+
export default macros;
|
|
11
|
+
|
|
7
12
|
import fontMetricsData from "./fontMetricsData";
|
|
8
13
|
import functions from "./functions";
|
|
9
14
|
import symbols from "./symbols";
|
|
10
15
|
import utils from "./utils";
|
|
11
|
-
import {Token} from "./Token";
|
|
12
16
|
import ParseError from "./ParseError";
|
|
13
|
-
import type Namespace from "./Namespace";
|
|
14
|
-
|
|
15
|
-
import type {Mode} from "./types";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Provides context to macros defined by functions. Implemented by
|
|
19
|
-
* MacroExpander.
|
|
20
|
-
*/
|
|
21
|
-
export interface MacroContextInterface {
|
|
22
|
-
mode: Mode;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Object mapping macros to their expansions.
|
|
26
|
-
*/
|
|
27
|
-
macros: Namespace<MacroDefinition>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Returns the topmost token on the stack, without expanding it.
|
|
31
|
-
* Similar in behavior to TeX's `\futurelet`.
|
|
32
|
-
*/
|
|
33
|
-
future(): Token;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Remove and return the next unexpanded token.
|
|
37
|
-
*/
|
|
38
|
-
popToken(): Token;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Consume all following space tokens, without expansion.
|
|
42
|
-
*/
|
|
43
|
-
consumeSpaces(): void;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Expand the next token only once if possible.
|
|
47
|
-
*/
|
|
48
|
-
expandOnce(expandableOnly?: boolean): Token | Token[];
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Expand the next token only once (if possible), and return the resulting
|
|
52
|
-
* top token on the stack (without removing anything from the stack).
|
|
53
|
-
* Similar in behavior to TeX's `\expandafter\futurelet`.
|
|
54
|
-
*/
|
|
55
|
-
expandAfterFuture(): Token;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Recursively expand first token, then return first non-expandable token.
|
|
59
|
-
*/
|
|
60
|
-
expandNextToken(): Token;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Fully expand the given macro name and return the resulting list of
|
|
64
|
-
* tokens, or return `undefined` if no such macro is defined.
|
|
65
|
-
*/
|
|
66
|
-
expandMacro(name: string): Token[] | void;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Fully expand the given macro name and return the result as a string,
|
|
70
|
-
* or return `undefined` if no such macro is defined.
|
|
71
|
-
*/
|
|
72
|
-
expandMacroAsText(name: string): string | void;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Consume an argument from the token stream, and return the resulting array
|
|
76
|
-
* of tokens and start/end token.
|
|
77
|
-
*/
|
|
78
|
-
consumeArg(delims?: ?string[]): MacroArg;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Consume the specified number of arguments from the token stream,
|
|
82
|
-
* and return the resulting array of arguments.
|
|
83
|
-
*/
|
|
84
|
-
consumeArgs(numArgs: number): Token[][];
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Determine whether a command is currently "defined" (has some
|
|
88
|
-
* functionality), meaning that it's a macro (in the current group),
|
|
89
|
-
* a function, a symbol, or one of the special commands listed in
|
|
90
|
-
* `implicitCommands`.
|
|
91
|
-
*/
|
|
92
|
-
isDefined(name: string): boolean;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Determine whether a command is expandable.
|
|
96
|
-
*/
|
|
97
|
-
isExpandable(name: string): boolean;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export type MacroArg = {
|
|
101
|
-
tokens: Token[],
|
|
102
|
-
start: Token,
|
|
103
|
-
end: Token
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
/** Macro tokens (in reverse order). */
|
|
107
|
-
export type MacroExpansion = {
|
|
108
|
-
tokens: Token[],
|
|
109
|
-
numArgs: number,
|
|
110
|
-
delimiters?: string[][],
|
|
111
|
-
unexpandable?: boolean, // used in \let
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export type MacroDefinition = string | MacroExpansion |
|
|
115
|
-
(MacroContextInterface => (string | MacroExpansion));
|
|
116
|
-
export type MacroMap = {[string]: MacroDefinition};
|
|
117
|
-
|
|
118
|
-
const builtinMacros: MacroMap = {};
|
|
119
|
-
export default builtinMacros;
|
|
120
17
|
|
|
121
|
-
// This function might one day accept an additional argument and do more things.
|
|
122
|
-
export function defineMacro(name: string, body: MacroDefinition) {
|
|
123
|
-
builtinMacros[name] = body;
|
|
124
|
-
}
|
|
125
18
|
|
|
126
19
|
//////////////////////////////////////////////////////////////////////
|
|
127
20
|
// macro tools
|