rapier-math 2.4.0 → 2.6.1
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 +10 -0
- package/LICENSE +10 -3
- package/README.md +4 -5
- package/dist/index.mjs +1 -1
- package/dist/markdown-rules.mjs +47 -0
- package/dist/rapier-math.js +678 -229
- package/docs/api.md +6 -2
- package/docs/font-source.md +37 -29
- package/docs/math-components.json +51 -7
- package/docs/math-resources.json +59 -64
- package/package.json +3 -3
- package/src/math/FONT-LICENSE.txt +9 -2
- package/src/math/build-font.py +61 -65
- package/src/math/classic.js +1 -1
- package/src/math/font.js +23 -487
- package/src/math/layout.js +302 -112
- package/src/math/mathml.js +26 -7
- package/src/math/package-layout.mjs +1 -0
- package/src/math/package-readme.mjs +3 -4
- package/src/math/parser.js +306 -67
- package/src/tools/build-math.mjs +22 -7
- package/tests/adoption.mjs +0 -252
- package/tests/check.mjs +0 -133
- package/tests/semantics.mjs +0 -340
- package/tests/typeset.mjs +0 -172
- package/tests/verify.mjs +0 -49
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.6.1
|
|
4
|
+
|
|
5
|
+
- Use the font's ellipses and correct extensible arrow sizes.
|
|
6
|
+
- Match amscd row spacing and under-accent attachment points.
|
|
7
|
+
- Correct chemistry labels, state spacing and superscripts. Keep chemistry arrows at least 2 em wide in MathML.
|
|
8
|
+
- Include the Latin Modern Mono sharp s outline for monospace text.
|
|
9
|
+
- Preserve exact math fence source in shared Markdown rules.
|
|
10
|
+
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Rapier Math
|
|
2
2
|
|
|
3
|
-
The renderer and build tools are MIT-licensed. The embedded Latin Modern
|
|
3
|
+
The renderer and build tools are MIT-licensed. The embedded Latin Modern outlines and metrics
|
|
4
4
|
are licensed separately under the GUST Font License. Both grants apply to this distribution.
|
|
5
5
|
|
|
6
6
|
MIT License
|
|
@@ -27,12 +27,19 @@ SOFTWARE.
|
|
|
27
27
|
|
|
28
28
|
Copyright 2012--2014 for Latin Modern Math OTF by B. Jackowski, P. Strzelczyk and P. Pianowski (on behalf of TeX users groups). This work is released under the GUST Font License -- see http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt for details.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Copyright 2003, 2009 B. Jackowski and J. M. Nowacki (on behalf of TeX users groups). This work is released under the GUST Font License -- see http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt for details.
|
|
31
|
+
|
|
32
|
+
Copyright 2003--2009 by B. Jackowski and J.M. Nowacki (on behalf of TeX USERS GROUPS).
|
|
33
|
+
|
|
34
|
+
Rapier math font data, derived from Latin Modern Math 1.959,
|
|
35
|
+
the sharp s of Latin Modern Mono 2.004, and one arrow hook
|
|
36
|
+
from Latin Modern Math Italic 10 Regular 2.003.
|
|
31
37
|
Changes: SVG outline conversion, character and MATH data extraction,
|
|
32
|
-
optical-form closure
|
|
38
|
+
optical-form closure and lossless path packing.
|
|
33
39
|
Original outlines are unchanged. Hinting and text shaping tables are omitted.
|
|
34
40
|
The font authors do not maintain this conversion.
|
|
35
41
|
Complete original work: https://mirrors.ctan.org/fonts/lm-math.zip
|
|
42
|
+
Mono and hook original work: https://mirrors.ctan.org/fonts/lm.zip
|
|
36
43
|
Conversion details: FONT-SOURCE.md.
|
|
37
44
|
|
|
38
45
|
% This is a preliminary version (2006-09-30), barring acceptance from
|
package/README.md
CHANGED
|
@@ -29,23 +29,22 @@ for host composition. All return synchronously. Type declarations accompany the
|
|
|
29
29
|
- [MathML, accessibility and source contracts](docs/semantics.md)
|
|
30
30
|
- [Runnable examples](examples/README.md)
|
|
31
31
|
- [Font source and regeneration](docs/font-source.md)
|
|
32
|
+
- [Changes](CHANGELOG.md)
|
|
32
33
|
|
|
33
34
|
## Develop
|
|
34
35
|
|
|
35
36
|
The classic script and native entry points live in `dist/`. Native entries import the editable
|
|
36
37
|
modules in `src/math/` directly, sharing one parser without a duplicate generated renderer. Build
|
|
37
|
-
tools live in `src/tools/`. Optional adapters have one source copy in `dist/`. Examples
|
|
38
|
+
tools live in `src/tools/`. Optional adapters have one source copy in `dist/`. Examples and documentation each
|
|
38
39
|
have their own directory. Only the current release is kept in this checkout.
|
|
39
40
|
|
|
40
|
-
From a repository checkout, run `node tests/check.mjs` and `node tests/verify.mjs` to check the package and rebuild its exact bytes.
|
|
41
41
|
Run `node src/tools/build-math.mjs --package .` to regenerate the classic and ESM files from source.
|
|
42
|
-
Optional host checks run with `node tests/adoption.mjs` after installing the example dependencies.
|
|
43
42
|
|
|
44
43
|
## License
|
|
45
44
|
|
|
46
|
-
The renderer and adapters are MIT-licensed. Embedded Latin Modern
|
|
45
|
+
The renderer and adapters are MIT-licensed. Embedded Latin Modern outlines and metrics are
|
|
47
46
|
licensed under the GUST Font License. [LICENSE](LICENSE) contains both complete grants.
|
|
48
47
|
[Component provenance](docs/math-components.json) and [source hashes](docs/math-resources.json)
|
|
49
48
|
travel with the package.
|
|
50
49
|
|
|
51
|
-
Version 2.
|
|
50
|
+
Version 2.6.1. Classic payload: 733943 bytes; gzip (level 9): 418021 bytes.
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
import {parseMathTex as parse} from '../src/math/parser.js';
|
|
3
3
|
import {renderMath as render, mathRenderToString as renderToString} from '../src/math/api.js';
|
|
4
4
|
import {mathFit as fit, mathObserve as observe} from '../src/math/browser.js';
|
|
5
|
-
const version = "2.
|
|
5
|
+
const version = "2.6.1";
|
|
6
6
|
export {version, parse, render, renderToString, fit, observe};
|
|
7
7
|
export default Object.freeze({version, parse, render, renderToString, fit, observe});
|
package/dist/markdown-rules.mjs
CHANGED
|
@@ -3,6 +3,53 @@
|
|
|
3
3
|
import {createMathMatcher} from './delimiters.mjs';
|
|
4
4
|
|
|
5
5
|
export function installMathRules(md, {singleDollar = false, brackets = true, ruleName = 'rapier_math', inLink = false} = {}) {
|
|
6
|
+
// Block tokens share their core owner's array, including nested quotes/lists. Capture
|
|
7
|
+
// fence source while the host still holds those containers' adjusted line bounds.
|
|
8
|
+
const authored = new WeakMap();
|
|
9
|
+
md.core.ruler.before('normalize', ruleName + '_source', state => {
|
|
10
|
+
authored.set(state.tokens, {source: state.src});
|
|
11
|
+
});
|
|
12
|
+
md.core.ruler.after('block', ruleName + '_source_release', state => authored.delete(state.tokens));
|
|
13
|
+
const tokenize = md.block.tokenize;
|
|
14
|
+
md.block.tokenize = function(state, startLine, endLine) {
|
|
15
|
+
const first = state.tokens.length;
|
|
16
|
+
// A yielding host can leave tokenize at a completed block boundary by throwing.
|
|
17
|
+
// Retain those completed fences before that boundary releases its line tables.
|
|
18
|
+
try { return tokenize.call(this, state, startLine, endLine); }
|
|
19
|
+
finally {
|
|
20
|
+
for (let index = first; index < state.tokens.length; index++) {
|
|
21
|
+
const token = state.tokens[index];
|
|
22
|
+
if (token.type !== 'fence' || !token.map || token.meta?.mathSource !== undefined ||
|
|
23
|
+
String(token.info || '').trim().split(/\s+/)[0].toLowerCase() !== 'math') continue;
|
|
24
|
+
const held = authored.get(state.tokens), source = held?.source ?? state.src;
|
|
25
|
+
let value;
|
|
26
|
+
if (!state.rapierSourceSlice && source === state.src) value = state.getLines(token.map[0], token.map[1], state.blkIndent, false);
|
|
27
|
+
else {
|
|
28
|
+
// Core normalization changes CRLF/CR and NUL, never the retained fence.
|
|
29
|
+
if (!state.rapierSourceSlice) {
|
|
30
|
+
const starts = text => [0, ...Array.from(text.matchAll(/\r\n?|\n/g), match => match.index + match[0].length)];
|
|
31
|
+
held.rawLines ||= starts(source);
|
|
32
|
+
held.lines ||= starts(state.src);
|
|
33
|
+
}
|
|
34
|
+
const view = Object.create(state), parts = [];
|
|
35
|
+
view.bMarks = []; view.eMarks = [];
|
|
36
|
+
for (let line = token.map[0]; line < token.map[1]; line++) {
|
|
37
|
+
const shift = state.rapierSourceSlice ? 0 : held.rawLines[line] - held.lines[line];
|
|
38
|
+
view.src = state.rapierSourceSlice
|
|
39
|
+
? state.rapierSourceSlice(state.bMarks[line], state.eMarks[line])
|
|
40
|
+
: source.slice(state.bMarks[line] + shift, state.eMarks[line] + shift);
|
|
41
|
+
view.bMarks[line] = 0; view.eMarks[line] = view.src.length;
|
|
42
|
+
parts.push(view.getLines(line, line + 1, state.blkIndent, false));
|
|
43
|
+
if (line + 1 < token.map[1]) parts.push(state.rapierSourceSlice
|
|
44
|
+
? state.rapierSourceSlice(state.eMarks[line], state.eMarks[line] + 1)
|
|
45
|
+
: source.slice(state.eMarks[line] + shift, held.rawLines[line + 1]));
|
|
46
|
+
}
|
|
47
|
+
value = parts.join('');
|
|
48
|
+
}
|
|
49
|
+
token.meta = {...token.meta, mathSource: value};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
6
53
|
// The host's image-alt renderer ignores unknown token types. Keep math as
|
|
7
54
|
// literal source in text-only output, while leaving escaping to that host.
|
|
8
55
|
const renderText = md.renderer.renderInlineAsText;
|