@matheos/core 0.2.3 → 0.4.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/dist/display.d.ts +9 -0
- package/dist/display.js +74 -0
- package/dist/display.js.map +1 -0
- package/dist/evaluate.d.ts +34 -0
- package/dist/evaluate.js +151 -179
- package/dist/evaluate.js.map +1 -1
- package/dist/fit.d.ts +24 -0
- package/dist/fit.js +151 -0
- package/dist/fit.js.map +1 -0
- package/dist/graph.js +4 -8
- package/dist/graph.js.map +1 -1
- package/dist/html.d.ts +25 -0
- package/dist/html.js +54 -56
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/model.d.ts +10 -7
- package/dist/parse.d.ts +50 -1
- package/dist/parse.js +124 -65
- package/dist/parse.js.map +1 -1
- package/dist/plot.d.ts +11 -17
- package/dist/plot.js +67 -3
- package/dist/plot.js.map +1 -1
- package/dist/printer.d.ts +32 -13
- package/dist/printer.js +105 -100
- package/dist/printer.js.map +1 -1
- package/dist/units.d.ts +4 -2
- package/dist/units.js +8 -2
- package/dist/units.js.map +1 -1
- package/dist/verdict.d.ts +21 -0
- package/dist/verdict.js +22 -0
- package/dist/verdict.js.map +1 -0
- package/package.json +1 -1
package/dist/html.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import katex from 'katex';
|
|
3
3
|
import { toHast } from 'mdast-util-to-hast';
|
|
4
4
|
import { toHtml as hastToHtml } from 'hast-util-to-html';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { plainText } from './printer.js';
|
|
6
|
+
import { badge, percent } from './verdict.js';
|
|
7
|
+
import { fitScript } from './fit.js';
|
|
8
|
+
// Fonts and KaTeX CSS: the hosts pass them through `head` (the CLI inlines data URIs, the editor its bundled files); a bare
|
|
9
|
+
// toHtml falls back to CDN links.
|
|
8
10
|
const CSS = `
|
|
9
11
|
@page { size: A4; margin: 22mm 18mm 20mm 22mm;
|
|
10
12
|
@top-left { content: var(--h-title); font: 8.5pt/1 "JetBrains Mono", monospace; color: #555; vertical-align: bottom; padding-bottom: 3mm; }
|
|
@@ -50,7 +52,7 @@ html { scrollbar-width: thin; }
|
|
|
50
52
|
.plot { margin: 2mm 0 3mm; text-align: center; break-inside: avoid; } .plot svg { max-width: 100%; height: auto; } /* a diagram sits centred on the page */
|
|
51
53
|
.cur { box-shadow: -5px 0 0 0 #ffb86c; } /* the block under the editor cursor: a thin bar in the left margin */
|
|
52
54
|
@media print { .cur { box-shadow: none; } }
|
|
53
|
-
.cond { color: #333; }
|
|
55
|
+
.cond, .loop { color: #333; }
|
|
54
56
|
.branch { border-left: 1.2pt solid #bbb; padding-left: 4mm; margin: 1mm 0 1mm 1mm; }
|
|
55
57
|
.err { font: 9pt "JetBrains Mono", monospace; color: #b00020; }
|
|
56
58
|
.katex-display { margin: 0; display: inline-block; text-align: left; }
|
|
@@ -60,55 +62,16 @@ html { scrollbar-width: thin; }
|
|
|
60
62
|
.stack .rhs .katex { display: inline-block; white-space: nowrap; text-indent: 0; margin-right: .45em; } /* KaTeX would otherwise break inside a term at its own relations */
|
|
61
63
|
.inline { font: 9.5pt "JetBrains Mono", monospace; }
|
|
62
64
|
`;
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
// the first unit that would overflow a 255 mm page, a heading moves along with the unit after it. Print ignores the gaps.
|
|
67
|
-
// On screen the page keeps its 210 mm and is zoomed down to a narrower pane, so the lines wrap exactly as they print; the
|
|
68
|
-
// fit measures through R(), which undoes the zoom (getBoundingClientRect is zoomed, offsetWidth and clientWidth are not).
|
|
69
|
-
const FIT = `(function(){var MM=96/25.4,PAGE_H=255*MM,GAP_H=52*MM,Z=1;function R(el){var r=el.getBoundingClientRect();return{left:r.left/Z,right:r.right/Z,top:r.top/Z,bottom:r.bottom/Z,width:r.width/Z};}
|
|
70
|
-
/* docs/spec/report.md, line sharing: the formula comes first and may take 80 % of the line (all of it without a caption,
|
|
71
|
-
65 % when the caption has to wrap, so that it keeps 25 %); the caption wraps in what is left after a 10 % gap, at most
|
|
72
|
-
60 %. A formula wider than its share wraps at its terms, then gives back the width it does not use. A single term wider
|
|
73
|
-
than the share takes the whole line and the caption drops under it; only a term wider than the line itself shrinks. */
|
|
74
|
-
function fit(){document.querySelectorAll('.st > span:first-child, .prose table').forEach(function(el){el.style.fontSize='';var box=el.parentElement,full=box.clientWidth,r=el.nextElementSibling;if(!(r&&r.classList.contains('right')&&r.textContent.trim()))r=null;box.classList.remove('below');
|
|
75
|
-
var one=el.querySelector(':scope > .one'),alt=el.querySelector(':scope > .alt');if(one&&alt){one.hidden=false;alt.hidden=true;alt.style.width='';}
|
|
76
|
-
var GAP=.1*full,CMAX=.6*full,CMIN=.25*full,avail=full,wf=one?R(one).width:Math.max(el.scrollWidth,R(el).width);
|
|
77
|
-
if(r){r.style.maxWidth='none';r.style.whiteSpace='nowrap';var wc=R(r).width;r.style.whiteSpace='';avail=wf+GAP+wc<=full?.8*full:full-GAP-CMIN;}
|
|
78
|
-
function caption(used){if(r&&!box.classList.contains('below'))r.style.maxWidth=Math.max(Math.min(CMAX,full-used-GAP),CMIN)+'px';}
|
|
79
|
-
function below(){if(r)box.classList.add('below');avail=full;} /* the formula needs the whole line: the caption drops under it */
|
|
80
|
-
if(one&&alt&&wf>avail){one.hidden=true;alt.hidden=false;alt.style.width=avail+'px';
|
|
81
|
-
/* pad = the name column before the rows; measured from the left edges, because the grid grows past the stack's width
|
|
82
|
-
when a term is wider than the row and the row's own width then tells nothing */
|
|
83
|
-
var rows=alt.querySelectorAll('.rhs'),widest=0,pad=0,left=R(alt).left,mr=function(t){return parseFloat(getComputedStyle(t).marginRight);};
|
|
84
|
-
rows.forEach(function(x){x.style.fontSize='';pad=Math.max(pad,R(x).left-left);x.querySelectorAll(':scope > .katex').forEach(function(t){widest=Math.max(widest,R(t).width+mr(t));});});
|
|
85
|
-
var room=avail-pad;if(widest>room&&r){below();alt.style.width=avail+'px';room=avail-pad;} /* one term wider than the share: the whole line */
|
|
86
|
-
if(room>0&&widest>room)rows.forEach(function(x){x.style.fontSize=Math.max(55,Math.floor(room/widest*100))+'%';}); /* wider than the line itself: the rows shrink */
|
|
87
|
-
var used=0;rows.forEach(function(x){x.querySelectorAll(':scope > .katex').forEach(function(t){used=Math.max(used,R(t).right+mr(t)-left);});});
|
|
88
|
-
alt.style.width=Math.min(avail,Math.ceil(used)+1)+'px';caption(alt.offsetWidth);return;} /* the stack keeps its wrapping and gives the rest to the caption */
|
|
89
|
-
if(wf>avail&&r)below();
|
|
90
|
-
if(wf>avail){el.style.fontSize=Math.max(55,Math.floor(avail/wf*100))+'%';wf=avail;}
|
|
91
|
-
caption(wf);});}
|
|
92
|
-
function paginate(){var page=document.querySelector('.page');if(!page||!matchMedia('screen').matches)return;document.querySelectorAll('.pagegap, .pageend').forEach(function(g){g.remove();});
|
|
93
|
-
var pad=parseFloat(getComputedStyle(page).paddingTop);if(!(pad>0))return;var units=page.querySelectorAll('.page > :not(.calc), .calc .st'),pageTop=0,n=1,prev=null;
|
|
94
|
-
var p0=R(page).top+pad,pw=page.offsetWidth,pl=R(page).left;
|
|
95
|
-
var rects=[];for(var i=0;i<units.length;i++){var r=R(units[i]);rects.push([r.top-p0,r.bottom-p0,r.left-pl]);} /* one measuring pass; gaps shift everything below by their own height, so the original coordinates stay valid */
|
|
96
|
-
var gaps=[];for(var i=0;i<units.length;i++){var el=units[i],t=rects[i][0],b=rects[i][1];
|
|
97
|
-
if(b-pageTop>PAGE_H&&t>pageTop){var ph=prev!==null?units[prev]:null,k=ph&&/^H[1-3]$/.test((ph.firstElementChild||ph).tagName)?prev:i,bt=rects[k][0];gaps.push([units[k],PAGE_H-(bt-pageTop)+GAP_H,rects[k][2]]);pageTop=bt;}
|
|
98
|
-
prev=i;}
|
|
99
|
-
for(var i=0;i<gaps.length;i++){var g=document.createElement('div');g.className='pagegap';g.setAttribute('data-page',i+2);g.style.height=gaps[i][1]+'px';g.style.marginLeft=(-gaps[i][2])+'px';g.style.width=pw+'px';gaps[i][0].parentNode.insertBefore(g,gaps[i][0]);}
|
|
100
|
-
n=gaps.length+1;var end=document.createElement('div');end.className='pageend';page.appendChild(end);
|
|
101
|
-
document.querySelectorAll('.pagegap, .pageend').forEach(function(g,i){g.setAttribute('data-foot','Page '+(i+1)+' of '+n);});}
|
|
102
|
-
function zoom(){var page=document.querySelector('.page');if(!page||!matchMedia('screen').matches)return;var vw=document.documentElement.clientWidth,pw=page.offsetWidth;page.style.zoom=vw<pw+12?String((vw-12)/pw):'';Z=R(page).width/pw*Z||1;}
|
|
103
|
-
function layout(){zoom();fit();paginate();}
|
|
104
|
-
var resizeTimer;window.fitWidth=layout;layout();if(document.fonts)document.fonts.ready.then(layout);
|
|
105
|
-
window.addEventListener('resize',function(){clearTimeout(resizeTimer);resizeTimer=setTimeout(layout,150);}); /* once the pane has settled, not on every frame of its animation */
|
|
106
|
-
})();`;
|
|
65
|
+
// The layout script (fit.ts): line sharing, screen pagination, the zoomed preview. Embedded as its own source, so the
|
|
66
|
+
// page runs exactly the function tsc checked and the tests table; `window.fitWidth` re-runs it after an in-place patch.
|
|
67
|
+
const FIT = `(${fitScript.toString()})(window, document)`;
|
|
107
68
|
const esc = (s) => String(s ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
108
69
|
const cssStr = (s) => `"${String(s ?? '').replace(/["\\]/g, '\\$&')}"`;
|
|
109
70
|
const tex = (latex, display = true) => katex.renderToString(latex, { throwOnError: false, displayMode: display });
|
|
110
71
|
/** A LaTeX piece split at its top-level ` + ` and ` - ` (outside braces and brackets): `a`, `+ b`, `- c`. Matrices and cases stay whole. */
|
|
111
|
-
|
|
72
|
+
/** A piece split into its top-level terms (at ` + ` and ` - `, signs carried), brackets and \left…\right kept whole, a
|
|
73
|
+
* matrix or cases block whole: the runs a stacked row wraps at. */
|
|
74
|
+
export function terms(piece) {
|
|
112
75
|
if (/\\begin\{/.test(piece))
|
|
113
76
|
return [piece];
|
|
114
77
|
const out = [];
|
|
@@ -141,7 +104,7 @@ function terms(piece) {
|
|
|
141
104
|
function statement(it) {
|
|
142
105
|
const cap = it.caption ? `<span class="cap">${esc(it.caption)}</span>` : '';
|
|
143
106
|
if (it.error)
|
|
144
|
-
return `<div class="st"><span class="err">✗ ${esc(it.error)}</span><span class="right">${cap}</span></div>`;
|
|
107
|
+
return `<div class="st" data-line="${it.pos.start.line}"><span class="err">✗ ${esc(it.error)}</span><span class="right">${cap}</span></div>`;
|
|
145
108
|
// one line when it fits; a long derived line carries a stacked alternative (name = formula, = substituted, = result)
|
|
146
109
|
// that the fit script swaps in only when the one-liner is wider than the page
|
|
147
110
|
const stackable = it.pieces && it.pieces.length > 2 && it.latex.length > 90;
|
|
@@ -157,11 +120,10 @@ function statement(it) {
|
|
|
157
120
|
}
|
|
158
121
|
let right = cap; // caption first, then the verdict
|
|
159
122
|
if (it.kind === 'function')
|
|
160
|
-
return `<div class="st derived"><span>${body}</span><span class="right">${right}</span></div>`;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
right += `<span class="badge ${it.verdict ? (it.warn ? 'warn' : 'ok') : 'fail'}">${it.verdict ? '✓ OK' : '✗ FAIL'}${it.kind === 'check' ? ` ${percent(it.eta)}` : ''}</span>`;
|
|
123
|
+
return `<div class="st derived" data-line="${it.pos.start.line}"><span>${body}</span><span class="right">${right}</span></div>`;
|
|
124
|
+
const b = badge(it);
|
|
125
|
+
if (b)
|
|
126
|
+
right += `<span class="badge ${b.state}">${b.text}${b.eta !== undefined ? ` ${percent(b.eta)}` : ''}</span>`;
|
|
165
127
|
return `<div class="st ${it.kind}" data-line="${it.pos.start.line}"><span>${body}</span><span class="right">${right}</span></div>`;
|
|
166
128
|
}
|
|
167
129
|
const resolveAsset = (path, assets) => {
|
|
@@ -171,7 +133,8 @@ const resolveAsset = (path, assets) => {
|
|
|
171
133
|
return path;
|
|
172
134
|
return assets?.(path);
|
|
173
135
|
};
|
|
174
|
-
|
|
136
|
+
// the stylesheet of the KaTeX that rendered the markup: a pinned number here drifted eight releases behind the installed one
|
|
137
|
+
const CDN_HEAD = `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@${katex.version}/dist/katex.min.css">
|
|
175
138
|
<link href="https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1,400..700&family=JetBrains+Mono:ital,wght@0,400..800;1,400..700&display=swap" rel="stylesheet">`;
|
|
176
139
|
export function toHtml(r, opts = {}) {
|
|
177
140
|
if (r.expanded)
|
|
@@ -249,4 +212,39 @@ ${parts.join('\n')}
|
|
|
249
212
|
</div>
|
|
250
213
|
<script>${FIT}</script></body></html>`;
|
|
251
214
|
}
|
|
215
|
+
/** What a host may do to a loaded report page: the preview beside the editor, the PDF run (docs/spec/report.md, "Screen
|
|
216
|
+
* preview"). The class and attribute names of the page stay in this file; hosts call these instead of spelling them.
|
|
217
|
+
* Every block and every statement row names its source line; the row under the editor cursor is marked. */
|
|
218
|
+
export const page = {
|
|
219
|
+
/** Blocks and statement rows, in document order. */
|
|
220
|
+
rows: (doc) => Array.from(doc.querySelectorAll('[data-line]')),
|
|
221
|
+
/** The source line of the row a node sits in. */
|
|
222
|
+
lineOf(node) {
|
|
223
|
+
const el = node ? (node.nodeType === 1 ? node : node.parentElement) : null;
|
|
224
|
+
return Number(el?.closest('[data-line]')?.getAttribute('data-line')) || undefined;
|
|
225
|
+
},
|
|
226
|
+
/** The row that starts at or before a source line. */
|
|
227
|
+
rowAt: (doc, line) => page.rows(doc).filter((e) => Number(e.dataset.line) <= line).pop(),
|
|
228
|
+
/** Marks the row of a source line as the current one. */
|
|
229
|
+
mark(doc, line) { const t = page.rowAt(doc, line); page.rows(doc).forEach((e) => e.classList.toggle('cur', e === t)); },
|
|
230
|
+
/** Patches a loaded report in place with a newer one: the page's content, any changed `<style>`, the title. False when
|
|
231
|
+
* the document is not a report yet or its head no longer lines up with the new one (a different number of styles):
|
|
232
|
+
* the host reloads instead of keeping stale CSS. */
|
|
233
|
+
patch(doc, html) {
|
|
234
|
+
const next = new DOMParser().parseFromString(html, 'text/html');
|
|
235
|
+
const now = doc.querySelector('.page'), nextPage = next.querySelector('.page');
|
|
236
|
+
const styles = doc.head.querySelectorAll('style'), nextStyles = next.head.querySelectorAll('style');
|
|
237
|
+
if (!now || !nextPage || styles.length !== nextStyles.length)
|
|
238
|
+
return false;
|
|
239
|
+
now.innerHTML = nextPage.innerHTML;
|
|
240
|
+
styles.forEach((st, i) => { const n = nextStyles[i]; if (n.textContent !== st.textContent)
|
|
241
|
+
st.textContent = n.textContent; });
|
|
242
|
+
doc.title = next.title;
|
|
243
|
+
return true;
|
|
244
|
+
},
|
|
245
|
+
/** Runs the page's layout again (line sharing, pagination, zoom): after a patch. */
|
|
246
|
+
refit(win) { win?.fitWidth?.(); },
|
|
247
|
+
/** The same for a browser driven from outside, once the fonts have settled. */
|
|
248
|
+
refitScript: 'document.fonts.ready.then(() => window.fitWidth && window.fitWidth())',
|
|
249
|
+
};
|
|
252
250
|
//# sourceMappingURL=html.js.map
|
package/dist/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAElD,4GAA4G;AAC5G,6FAA6F;AAC7F,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDX,CAAC;AAEF,4GAA4G;AAC5G,mHAAmH;AACnH,yHA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se.js';
|
|
2
|
+
export type { Anatomy, Span } from './parse.js';
|
|
3
|
+
export { evaluate, statements, byLine, parameters, substituteVar, spliceLoops, catalogueTables } from './evaluate.js';
|
|
4
|
+
export { toHtml, page } from './html.js';
|
|
4
5
|
export { graph } from './graph.js';
|
|
5
6
|
export type { Graph, GraphNode, GraphEdge } from './graph.js';
|
|
6
|
-
export { print, identifier, formatNumber,
|
|
7
|
+
export { print, identifier, formatNumber, stamp, plainText, comparison, implies, not, text, literalEcho, range } from './printer.js';
|
|
8
|
+
export { display } from './display.js';
|
|
9
|
+
export { badge, percent, summary } from './verdict.js';
|
|
10
|
+
export type { Badge, BadgeState } from './verdict.js';
|
|
7
11
|
export type { EvalOptions } from './evaluate.js';
|
|
8
|
-
export { math, unitLatex, displayUnit, UNITS } from './units.js';
|
|
12
|
+
export { math, unitLatex, displayUnit, displayName, isDimensionless, isUnit, UNITS } from './units.js';
|
|
9
13
|
export type * from './model.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export { parse } from './parse.js';
|
|
2
|
-
export { evaluate, statements } from './evaluate.js';
|
|
3
|
-
export { toHtml } from './html.js';
|
|
1
|
+
export { parse, anatomy } from './parse.js';
|
|
2
|
+
export { evaluate, statements, byLine, parameters, substituteVar, spliceLoops, catalogueTables } from './evaluate.js';
|
|
3
|
+
export { toHtml, page } from './html.js';
|
|
4
4
|
export { graph } from './graph.js';
|
|
5
|
-
export { print, identifier, formatNumber,
|
|
6
|
-
export {
|
|
5
|
+
export { print, identifier, formatNumber, stamp, plainText, comparison, implies, not, text, literalEcho, range } from './printer.js';
|
|
6
|
+
export { display } from './display.js';
|
|
7
|
+
export { badge, percent, summary } from './verdict.js';
|
|
8
|
+
export { math, unitLatex, displayUnit, displayName, isDimensionless, isUnit, UNITS } from './units.js';
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACtH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrI,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/model.d.ts
CHANGED
|
@@ -28,11 +28,6 @@ export interface FrontMatter {
|
|
|
28
28
|
include?: string | string[];
|
|
29
29
|
[key: string]: unknown;
|
|
30
30
|
}
|
|
31
|
-
export interface Catalog {
|
|
32
|
-
file: string;
|
|
33
|
-
units?: Record<string, string>;
|
|
34
|
-
key?: string;
|
|
35
|
-
}
|
|
36
31
|
export type Modifier = ';' | ':';
|
|
37
32
|
export type CmpOp = '<=' | '>=' | '<' | '>' | '==' | '!=';
|
|
38
33
|
interface Base {
|
|
@@ -42,10 +37,13 @@ interface Base {
|
|
|
42
37
|
modifier?: Modifier;
|
|
43
38
|
options?: string[];
|
|
44
39
|
}
|
|
40
|
+
/** `literal` and `unit`: the two halves of `expr` as typed (`6.0`, `m`), which the result line echoes. */
|
|
45
41
|
export interface Input extends Base {
|
|
46
42
|
kind: 'input';
|
|
47
43
|
name: string;
|
|
48
44
|
expr: string;
|
|
45
|
+
literal: string;
|
|
46
|
+
unit?: string;
|
|
49
47
|
param?: boolean;
|
|
50
48
|
}
|
|
51
49
|
export interface Derived extends Base {
|
|
@@ -103,6 +101,7 @@ export interface Inline {
|
|
|
103
101
|
showName: boolean;
|
|
104
102
|
pos: Pos;
|
|
105
103
|
plain?: boolean;
|
|
104
|
+
to?: string; /** `{M to kNm}`: the display unit */
|
|
106
105
|
}
|
|
107
106
|
export interface Prose {
|
|
108
107
|
kind: 'prose';
|
|
@@ -156,12 +155,12 @@ export interface Document {
|
|
|
156
155
|
text: string;
|
|
157
156
|
}
|
|
158
157
|
export interface RenderedStatement {
|
|
159
|
-
kind: 'input' | 'derived' | 'bare' | 'check' | 'cond' | 'function';
|
|
158
|
+
kind: 'input' | 'derived' | 'bare' | 'check' | 'cond' | 'loop' | 'function';
|
|
160
159
|
latex: string;
|
|
161
160
|
pieces?: string[];
|
|
162
161
|
caption?: string;
|
|
163
162
|
verdict?: boolean;
|
|
164
|
-
eta?:
|
|
163
|
+
eta?: number;
|
|
165
164
|
warn?: boolean;
|
|
166
165
|
na?: boolean;
|
|
167
166
|
warning?: string;
|
|
@@ -207,6 +206,10 @@ export interface RenderedError {
|
|
|
207
206
|
message: string;
|
|
208
207
|
pos: Pos;
|
|
209
208
|
}
|
|
209
|
+
/** Two passes, each for its readers. This one is the evaluation: `blocks[i]` renders `doc.blocks[i]` (the editor relies on
|
|
210
|
+
* it), `errors`, checks and `scope` are complete, a prose loop is one block. `expanded` is the print: the same document
|
|
211
|
+
* with its prose loops spliced into the source, so their rows join the table or drawing around them; a loop that failed
|
|
212
|
+
* is absent from it, its error is here. Checks, errors and values are read from this pass, the report from `expanded`. */
|
|
210
213
|
export interface Rendered {
|
|
211
214
|
frontMatter: FrontMatter;
|
|
212
215
|
blocks: RenderedBlock[];
|
package/dist/parse.d.ts
CHANGED
|
@@ -1,2 +1,51 @@
|
|
|
1
|
-
import type { Document } from './model.js';
|
|
1
|
+
import type { Document, Modifier } from './model.js';
|
|
2
2
|
export declare function parse(text: string): Document;
|
|
3
|
+
export interface Span {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
}
|
|
7
|
+
/** Where the parts of one statement line sit, as offsets into the line (docs/spec/grammar.md). The parser builds the
|
|
8
|
+
* statement from these spans and the editor colours them, so the two cannot disagree on what a line is. Tolerant: a
|
|
9
|
+
* half-typed line gets the spans that are there. */
|
|
10
|
+
export interface Anatomy {
|
|
11
|
+
/** the keyword that opens the line */
|
|
12
|
+
head?: 'check' | 'if' | 'else if' | 'else' | 'end' | 'for';
|
|
13
|
+
keyword?: Span;
|
|
14
|
+
/** `# …` to the end of the line */
|
|
15
|
+
caption?: Span;
|
|
16
|
+
modifier?: {
|
|
17
|
+
at: number;
|
|
18
|
+
mark: Modifier;
|
|
19
|
+
};
|
|
20
|
+
/** the `?` of a parameter, and its choices between the brackets */
|
|
21
|
+
param?: {
|
|
22
|
+
at: number;
|
|
23
|
+
options?: Span;
|
|
24
|
+
};
|
|
25
|
+
/** `check … warn 80%` */
|
|
26
|
+
warn?: {
|
|
27
|
+
word: Span;
|
|
28
|
+
value: number;
|
|
29
|
+
};
|
|
30
|
+
/** `check … if cond` */
|
|
31
|
+
only?: {
|
|
32
|
+
word: Span;
|
|
33
|
+
cond: Span;
|
|
34
|
+
};
|
|
35
|
+
/** `… to kN m`: the display unit */
|
|
36
|
+
to?: {
|
|
37
|
+
word: Span;
|
|
38
|
+
unit: Span;
|
|
39
|
+
};
|
|
40
|
+
/** the name assigned, defined or looped over; `lhs` adds an index (`K[i, j]`) */
|
|
41
|
+
name?: Span;
|
|
42
|
+
lhs?: Span;
|
|
43
|
+
/** the parameters of a function definition */
|
|
44
|
+
params?: string[];
|
|
45
|
+
/** an input's literal and its unit */
|
|
46
|
+
literal?: Span;
|
|
47
|
+
unit?: Span;
|
|
48
|
+
/** the expression: a right-hand side, a check's comparison, a condition, a loop range */
|
|
49
|
+
body: Span;
|
|
50
|
+
}
|
|
51
|
+
export declare function anatomy(line: string): Anatomy;
|
package/dist/parse.js
CHANGED
|
@@ -88,9 +88,12 @@ function inlinesOf(node) {
|
|
|
88
88
|
if (!/^[A-Za-z_Ͱ-Ͽ(\d-]/.test(body))
|
|
89
89
|
continue; // `{` of CSS or JS inside raw HTML, not an expression
|
|
90
90
|
const showName = /\s*=$/.test(body);
|
|
91
|
-
|
|
91
|
+
let expr = body.replace(/\s*=$/, '').trim();
|
|
92
|
+
const tm = TO.exec(expr), to = tm?.[1]; // `{U to %}`, `{M to kNm}`
|
|
93
|
+
if (tm)
|
|
94
|
+
expr = expr.slice(0, tm.index).trim();
|
|
92
95
|
const start = t.position.start.offset + m.index;
|
|
93
|
-
out.push({ raw: m[0], expr, showName, pos: { start: { ...t.position.start, offset: start }, end: { ...t.position.start, offset: start + m[0].length } }, ...(plain && { plain }) });
|
|
96
|
+
out.push({ raw: m[0], expr, showName, pos: { start: { ...t.position.start, offset: start }, end: { ...t.position.start, offset: start + m[0].length } }, ...(plain && { plain }), ...(to && { to }) });
|
|
94
97
|
}
|
|
95
98
|
};
|
|
96
99
|
const visit = (n) => {
|
|
@@ -121,39 +124,42 @@ function parseStatements(lines, from, to, posOf) {
|
|
|
121
124
|
i++;
|
|
122
125
|
continue;
|
|
123
126
|
}
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
// the keyword lines of a block, read through the line anatomy (a trailing comment does not hide an `end`)
|
|
128
|
+
const at = (k) => { const a = anatomy(lines[k]); return { head: a.head, name: a.name && lines[k].slice(a.name.from, a.name.to), body: lines[k].slice(a.body.from, a.body.to) }; };
|
|
129
|
+
const opens = (h, body) => (h === 'if' || h === 'for') && body !== '';
|
|
130
|
+
const here = at(i);
|
|
131
|
+
if (here.head === 'for' && here.name && here.body) {
|
|
126
132
|
let depth = 0, j = i + 1;
|
|
127
133
|
for (; j < to; j++) {
|
|
128
|
-
const t =
|
|
129
|
-
if (
|
|
134
|
+
const t = at(j);
|
|
135
|
+
if (opens(t.head, t.body))
|
|
130
136
|
depth++;
|
|
131
|
-
else if (t === 'end') {
|
|
137
|
+
else if (t.head === 'end') {
|
|
132
138
|
if (depth === 0)
|
|
133
139
|
break;
|
|
134
140
|
depth--;
|
|
135
141
|
}
|
|
136
142
|
}
|
|
137
|
-
out.push({ kind: 'for', raw, pos, variable:
|
|
143
|
+
out.push({ kind: 'for', raw, pos, variable: here.name, range: here.body, statements: parseStatements(lines, i + 1, j, posOf) });
|
|
138
144
|
i = j + 1;
|
|
139
145
|
continue;
|
|
140
146
|
}
|
|
141
|
-
if (
|
|
147
|
+
if (here.head === 'if' && here.body) {
|
|
142
148
|
const branches = [];
|
|
143
|
-
let cond =
|
|
149
|
+
let cond = here.body;
|
|
144
150
|
let bStart = i + 1, bPos = pos, depth = 0, j = i + 1;
|
|
145
151
|
for (; j < to; j++) {
|
|
146
|
-
const t =
|
|
147
|
-
if (
|
|
152
|
+
const t = at(j);
|
|
153
|
+
if (opens(t.head, t.body))
|
|
148
154
|
depth++;
|
|
149
|
-
else if (t === 'end') {
|
|
155
|
+
else if (t.head === 'end') {
|
|
150
156
|
if (depth === 0)
|
|
151
157
|
break;
|
|
152
158
|
depth--;
|
|
153
159
|
}
|
|
154
|
-
else if (depth === 0 && (
|
|
160
|
+
else if (depth === 0 && ((t.head === 'else if' && t.body) || (t.head === 'else' && !t.body))) {
|
|
155
161
|
branches.push({ condition: cond, pos: bPos, statements: parseStatements(lines, bStart, j, posOf) });
|
|
156
|
-
cond = t === 'else' ? undefined : t.
|
|
162
|
+
cond = t.head === 'else' ? undefined : t.body;
|
|
157
163
|
bStart = j + 1;
|
|
158
164
|
bPos = posOf(j);
|
|
159
165
|
}
|
|
@@ -219,68 +225,121 @@ function depthOf(s) {
|
|
|
219
225
|
}
|
|
220
226
|
return d;
|
|
221
227
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
228
|
+
const NAME = /^[A-Za-z_Ͱ-Ͽ][\wͰ-Ͽ']*/;
|
|
229
|
+
export function anatomy(line) {
|
|
230
|
+
const hash = line.indexOf('#');
|
|
231
|
+
let start = 0, end = hash >= 0 ? hash : line.length;
|
|
232
|
+
const trim = () => { while (start < end && /\s/.test(line[start]))
|
|
233
|
+
start++; while (end > start && /\s/.test(line[end - 1]))
|
|
234
|
+
end--; };
|
|
235
|
+
const code = () => line.slice(start, end);
|
|
236
|
+
const a = { body: { from: 0, to: 0 } };
|
|
237
|
+
const done = () => { trim(); a.body = { from: start, to: end }; return a; };
|
|
238
|
+
if (hash >= 0)
|
|
239
|
+
a.caption = { from: hash, to: line.length };
|
|
240
|
+
trim();
|
|
241
|
+
const kw = /^(else if|if|else|end|for)(?=\s|$)/.exec(code());
|
|
242
|
+
if (kw) {
|
|
243
|
+
a.head = kw[1];
|
|
244
|
+
a.keyword = { from: start, to: start + kw[1].length };
|
|
245
|
+
start += kw[1].length;
|
|
246
|
+
trim();
|
|
247
|
+
const loop = a.head === 'for' ? /^([A-Za-z_]\w*)\s*=\s*/.exec(code()) : null;
|
|
248
|
+
if (loop) {
|
|
249
|
+
a.name = a.lhs = { from: start, to: start + loop[1].length };
|
|
250
|
+
start += loop[0].length;
|
|
251
|
+
}
|
|
252
|
+
return done();
|
|
229
253
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
s = s.slice(0, -1).trim();
|
|
254
|
+
if (/[;:]$/.test(code())) {
|
|
255
|
+
a.modifier = { at: end - 1, mark: line[end - 1] };
|
|
256
|
+
end--;
|
|
257
|
+
trim();
|
|
235
258
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
s = s.slice(0, om.index).trim();
|
|
259
|
+
const om = /\?\s*\[([^\]]*)\]$/.exec(code()); // `reinf = "none" ? ["multiple", "single", "none"]`: a parameter with its choices
|
|
260
|
+
if (om && !/\?.*:/.test(code().slice(0, om.index))) {
|
|
261
|
+
a.param = { at: start + om.index, options: { from: end - 1 - om[1].length, to: end - 1 } };
|
|
262
|
+
end = start + om.index;
|
|
263
|
+
trim();
|
|
242
264
|
}
|
|
243
|
-
else if (
|
|
244
|
-
param =
|
|
245
|
-
|
|
265
|
+
else if (code().endsWith('?') && !/\?.*:/.test(code())) {
|
|
266
|
+
a.param = { at: end - 1 };
|
|
267
|
+
end--;
|
|
268
|
+
trim();
|
|
246
269
|
} // `L = 6 m ?`: a parameter (a ternary has `? … :`)
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
270
|
+
if (code().startsWith('check ')) {
|
|
271
|
+
a.head = 'check';
|
|
272
|
+
a.keyword = { from: start, to: start + 5 };
|
|
273
|
+
start += 6;
|
|
250
274
|
for (let k = 0; k < 2; k++) { // `check a <= b warn 80% if cond`, in either order
|
|
251
|
-
const wm = /\s+warn\s+(\d*\.?\d+)\s*(%?)\s*$/.exec(
|
|
252
|
-
if (wm && warn
|
|
253
|
-
|
|
254
|
-
warn = Number(wm[
|
|
275
|
+
const wm = /\s+(warn)\s+(\d*\.?\d+)\s*(%?)\s*$/.exec(code());
|
|
276
|
+
if (wm && !a.warn) {
|
|
277
|
+
const at = start + wm.index + wm[0].indexOf('warn');
|
|
278
|
+
a.warn = { word: { from: at, to: at + 4 }, value: Number(wm[2]) / (wm[3] ? 100 : 1) };
|
|
279
|
+
end = start + wm.index;
|
|
255
280
|
}
|
|
256
|
-
const im = /\s+if\s+(.+?)\s*$/.exec(
|
|
257
|
-
if (im && only
|
|
258
|
-
|
|
259
|
-
only = im[1];
|
|
281
|
+
const im = /\s+if\s+(.+?)\s*$/.exec(code());
|
|
282
|
+
if (im && !a.only) {
|
|
283
|
+
const at = start + im.index + im[0].indexOf('if');
|
|
284
|
+
a.only = { word: { from: at, to: at + 2 }, cond: { from: end - im[1].length, to: end } };
|
|
285
|
+
end = start + im.index;
|
|
260
286
|
}
|
|
261
287
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
288
|
+
return done();
|
|
289
|
+
}
|
|
290
|
+
const fm = /^([A-Za-z_Ͱ-Ͽ][\wͰ-Ͽ']*)\s*\(([^)]*)\)\s*=(?!=)\s*(.+)$/.exec(code());
|
|
291
|
+
if (fm) {
|
|
292
|
+
a.name = a.lhs = { from: start, to: start + fm[1].length };
|
|
293
|
+
a.params = fm[2].split(',').map((x) => x.trim()).filter(Boolean);
|
|
294
|
+
start = end - fm[3].length;
|
|
295
|
+
return done();
|
|
266
296
|
}
|
|
267
|
-
const
|
|
268
|
-
if (fm)
|
|
269
|
-
return { kind: 'function', ...base, name: fm[1].replace(/'/g, '$p'), params: fm[2].split(',').map((p) => p.trim().replace(/'/g, '$p')).filter(Boolean), expr: fm[3] };
|
|
270
|
-
let to;
|
|
271
|
-
const tm = TO.exec(s);
|
|
297
|
+
const tm = TO.exec(code());
|
|
272
298
|
if (tm) {
|
|
273
|
-
|
|
274
|
-
|
|
299
|
+
const at = start + tm.index + tm[0].indexOf('to');
|
|
300
|
+
a.to = { word: { from: at, to: at + 2 }, unit: { from: end - tm[1].length, to: end } };
|
|
301
|
+
end = start + tm.index;
|
|
302
|
+
trim();
|
|
275
303
|
}
|
|
276
|
-
const am = IDENT.exec(
|
|
304
|
+
const am = IDENT.exec(code());
|
|
277
305
|
if (am) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
306
|
+
a.lhs = { from: start, to: start + am[1].length };
|
|
307
|
+
a.name = { from: start, to: start + NAME.exec(am[1])[0].length };
|
|
308
|
+
start = end - am[2].length;
|
|
309
|
+
const lit = a.to ? null : LITERAL.exec(code());
|
|
310
|
+
if (lit) {
|
|
311
|
+
const u = lit[1] ?? '';
|
|
312
|
+
a.literal = { from: start, to: end - u.length };
|
|
313
|
+
if (u)
|
|
314
|
+
a.unit = { from: end - u.trimStart().length, to: end };
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return done();
|
|
318
|
+
}
|
|
319
|
+
function parseStatement(raw, pos) {
|
|
320
|
+
const a = anatomy(raw);
|
|
321
|
+
const cut = (x) => raw.slice(x.from, x.to);
|
|
322
|
+
const prime = (x) => x.replace(/'/g, '$p'); // primes are part of the name; math.js reads `'` as transpose
|
|
323
|
+
const caption = a.caption ? raw.slice(a.caption.from + 1).trim() : undefined;
|
|
324
|
+
const options = a.param?.options ? cut(a.param.options).split(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/).map((o) => o.trim()).filter(Boolean) : undefined;
|
|
325
|
+
const param = !!a.param;
|
|
326
|
+
const base = { raw, pos, ...(caption !== undefined && { caption }), ...(a.modifier && { modifier: a.modifier.mark }), ...(options && { options }) };
|
|
327
|
+
const body = cut(a.body);
|
|
328
|
+
if (a.head === 'check') {
|
|
329
|
+
const m = topCmp(body); // the comparison outside any bracket, so `check (a > 0 ? x : y) <= c` splits at `<=`
|
|
330
|
+
if (!m)
|
|
331
|
+
return { kind: 'bare', ...base, expr: body };
|
|
332
|
+
return { kind: 'check', ...base, left: body.slice(0, m.index).trim(), op: m.op, right: body.slice(m.index + m.op.length).trim(), ...(a.warn && { warn: a.warn.value }), ...(a.only && { only: cut(a.only.cond) }) };
|
|
333
|
+
}
|
|
334
|
+
if (a.params)
|
|
335
|
+
return { kind: 'function', ...base, name: prime(cut(a.name)), params: a.params.map(prime), expr: body };
|
|
336
|
+
const to = a.to ? cut(a.to.unit) : undefined;
|
|
337
|
+
if (a.lhs) {
|
|
338
|
+
const name = prime(cut(a.lhs));
|
|
339
|
+
if (a.literal)
|
|
340
|
+
return { kind: 'input', ...base, name, expr: body, literal: cut(a.literal), ...(a.unit && { unit: cut(a.unit) }), ...(param && { param }) };
|
|
341
|
+
return { kind: 'derived', ...base, name, expr: body, ...(to && { to }), ...(param && { param }) };
|
|
283
342
|
}
|
|
284
|
-
return { kind: 'bare', ...base, expr:
|
|
343
|
+
return { kind: 'bare', ...base, expr: body, ...(to && { to }) };
|
|
285
344
|
}
|
|
286
345
|
//# sourceMappingURL=parse.js.map
|