@schemd/core 0.2.0 → 0.3.0
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 +46 -0
- package/README.md +91 -27
- package/dist/compiler.d.ts +39 -0
- package/dist/compiler.js +17 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/layout.d.ts +49 -2
- package/dist/layout.js +556 -73
- package/dist/math-label.js +1 -22
- package/dist/parser.js +417 -42
- package/dist/renderer.js +377 -65
- package/dist/route-cache.d.ts +6 -0
- package/dist/route-cache.js +10 -0
- package/dist/types.d.ts +124 -19
- package/dist/types.js +167 -4
- package/dist/xml.d.ts +6 -0
- package/dist/xml.js +38 -0
- package/package.json +83 -74
package/dist/math-label.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { escapeXml } from './xml.js';
|
|
1
2
|
const MATH_SYMBOLS = Object.freeze({
|
|
2
3
|
alpha: 'α',
|
|
3
4
|
beta: 'β',
|
|
@@ -20,28 +21,6 @@ const MATH_SYMBOLS = Object.freeze({
|
|
|
20
21
|
theta: 'θ',
|
|
21
22
|
times: '×'
|
|
22
23
|
});
|
|
23
|
-
function validXmlCodePoint(codePoint) {
|
|
24
|
-
if (codePoint === 0x09 || codePoint === 0x0a || codePoint === 0x0d)
|
|
25
|
-
return true;
|
|
26
|
-
if (codePoint >= 0x20 && codePoint <= 0xd7ff)
|
|
27
|
-
return true;
|
|
28
|
-
if (codePoint >= 0xe000 && codePoint <= 0xfffd)
|
|
29
|
-
return true;
|
|
30
|
-
return codePoint >= 0x10000 && codePoint <= 0x10ffff;
|
|
31
|
-
}
|
|
32
|
-
function escapeXml(value) {
|
|
33
|
-
let normalized = '';
|
|
34
|
-
for (const character of value) {
|
|
35
|
-
const codePoint = character.codePointAt(0);
|
|
36
|
-
normalized += validXmlCodePoint(codePoint) ? character : '\ufffd';
|
|
37
|
-
}
|
|
38
|
-
return normalized
|
|
39
|
-
.replaceAll('&', '&')
|
|
40
|
-
.replaceAll('<', '<')
|
|
41
|
-
.replaceAll('>', '>')
|
|
42
|
-
.replaceAll('"', '"')
|
|
43
|
-
.replaceAll("'", ''');
|
|
44
|
-
}
|
|
45
24
|
function commandAt(value, index) {
|
|
46
25
|
const escaped = value[index + 1];
|
|
47
26
|
if (escaped === '\\' ||
|