katex 0.16.9 → 0.16.11
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/README.md +3 -3
- package/contrib/copy-tex/README.md +2 -2
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +3 -3
- package/dist/contrib/auto-render.js +39 -47
- package/dist/contrib/auto-render.min.js +1 -1
- package/dist/contrib/copy-tex.js +24 -27
- package/dist/contrib/copy-tex.min.js +1 -1
- package/dist/contrib/mathtex-script-type.js +3 -3
- package/dist/contrib/mathtex-script-type.min.js +1 -1
- package/dist/contrib/mhchem.js +116 -116
- package/dist/contrib/render-a11y-string.js +52 -43
- package/dist/contrib/render-a11y-string.min.js +1 -1
- package/dist/katex.css +239 -116
- package/dist/katex.js +3404 -3235
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +69 -27
- package/package.json +7 -6
- package/src/MacroExpander.js +16 -5
- package/src/Parser.js +4 -3
- package/src/Settings.js +5 -1
- package/src/domTree.js +6 -5
- package/src/fontMetrics.js +1 -1
- package/src/functions/text.js +7 -3
- package/src/styles/fonts.scss +71 -0
- package/src/{katex.less → styles/katex.scss} +21 -45
- package/src/symbols.js +3 -3
- package/src/utils.js +23 -4
- package/src/fonts.less +0 -64
package/src/utils.js
CHANGED
|
@@ -93,11 +93,30 @@ export const assert = function<T>(value: ?T): T {
|
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* Return the protocol of a URL, or "_relative" if the URL does not specify a
|
|
96
|
-
* protocol (and thus is relative)
|
|
96
|
+
* protocol (and thus is relative), or `null` if URL has invalid protocol
|
|
97
|
+
* (so should be outright rejected).
|
|
97
98
|
*/
|
|
98
|
-
export const protocolFromUrl = function(url: string): string {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
export const protocolFromUrl = function(url: string): string | null {
|
|
100
|
+
// Check for possible leading protocol.
|
|
101
|
+
// https://url.spec.whatwg.org/#url-parsing strips leading whitespace
|
|
102
|
+
// (U+20) or C0 control (U+00-U+1F) characters.
|
|
103
|
+
// eslint-disable-next-line no-control-regex
|
|
104
|
+
const protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i
|
|
105
|
+
.exec(url);
|
|
106
|
+
if (!protocol) {
|
|
107
|
+
return "_relative";
|
|
108
|
+
}
|
|
109
|
+
// Reject weird colons
|
|
110
|
+
if (protocol[2] !== ":") {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
// Reject invalid characters in scheme according to
|
|
114
|
+
// https://datatracker.ietf.org/doc/html/rfc3986#section-3.1
|
|
115
|
+
if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
// Lowercase the protocol
|
|
119
|
+
return protocol[1].toLowerCase();
|
|
101
120
|
};
|
|
102
121
|
|
|
103
122
|
export default {
|
package/src/fonts.less
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
@font-folder: "../fonts";
|
|
2
|
-
@use-ttf: true;
|
|
3
|
-
@use-woff: true;
|
|
4
|
-
@use-woff2: true;
|
|
5
|
-
|
|
6
|
-
.use-woff2(@family, @family-suffix) when (@use-woff2 = true) {
|
|
7
|
-
src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.woff2') format('woff2')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.use-woff(@family, @family-suffix) when (@use-woff = true) {
|
|
11
|
-
src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.woff') format('woff')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.use-ttf(@family, @family-suffix) when (@use-ttf = true) {
|
|
15
|
-
src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.ttf') format('truetype')
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.generate-suffix(@weight, @style) when (@weight = normal) and (@style = normal) {
|
|
19
|
-
@suffix: 'Regular';
|
|
20
|
-
}
|
|
21
|
-
.generate-suffix(@weight, @style) when (@weight = normal) and (@style = italic) {
|
|
22
|
-
@suffix: 'Italic';
|
|
23
|
-
}
|
|
24
|
-
.generate-suffix(@weight, @style) when (@weight = bold) and (@style = normal) {
|
|
25
|
-
@suffix: 'Bold';
|
|
26
|
-
}
|
|
27
|
-
.generate-suffix(@weight, @style) when (@weight = bold) and (@style = italic) {
|
|
28
|
-
@suffix: 'BoldItalic';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.font-face(@family, @weight, @style) {
|
|
32
|
-
.generate-suffix(@weight, @style);
|
|
33
|
-
@font-face {
|
|
34
|
-
font-family: 'KaTeX_@{family}';
|
|
35
|
-
.use-woff2(@family, @suffix);
|
|
36
|
-
.use-woff(@family, @suffix);
|
|
37
|
-
.use-ttf(@family, @suffix);
|
|
38
|
-
font-weight: @weight;
|
|
39
|
-
font-style: @style;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.font-face('AMS', normal, normal);
|
|
44
|
-
.font-face('Caligraphic', bold, normal);
|
|
45
|
-
.font-face('Caligraphic', normal, normal);
|
|
46
|
-
.font-face('Fraktur', bold, normal);
|
|
47
|
-
.font-face('Fraktur', normal, normal);
|
|
48
|
-
.font-face('Main', bold, normal);
|
|
49
|
-
.font-face('Main', bold, italic);
|
|
50
|
-
.font-face('Main', normal, italic);
|
|
51
|
-
.font-face('Main', normal, normal);
|
|
52
|
-
//.font-face('Math', bold, normal);
|
|
53
|
-
.font-face('Math', bold, italic);
|
|
54
|
-
.font-face('Math', normal, italic);
|
|
55
|
-
//.font-face('Math', normal, normal);
|
|
56
|
-
.font-face('SansSerif', bold, normal);
|
|
57
|
-
.font-face('SansSerif', normal, italic);
|
|
58
|
-
.font-face('SansSerif', normal, normal);
|
|
59
|
-
.font-face('Script', normal, normal);
|
|
60
|
-
.font-face('Size1', normal, normal);
|
|
61
|
-
.font-face('Size2', normal, normal);
|
|
62
|
-
.font-face('Size3', normal, normal);
|
|
63
|
-
.font-face('Size4', normal, normal);
|
|
64
|
-
.font-face('Typewriter', normal, normal);
|