@danielsimonjr/mathts-workbook 0.4.1 → 0.4.2
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/{chunk-JM3ZAYJC.js → chunk-4P6ZKIDU.js} +1 -1
- package/dist/cli.js +13 -8
- package/dist/index.js +1 -1
- package/dist/markdown.d.ts +7 -0
- package/dist/markdown.d.ts.map +1 -1
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
runWorkbookWithTimeout,
|
|
16
16
|
setMetadata,
|
|
17
17
|
writeFileAtomic
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4P6ZKIDU.js";
|
|
19
19
|
import {
|
|
20
20
|
buildDependencyGraph,
|
|
21
21
|
createExecutor,
|
|
@@ -162,6 +162,9 @@ function texEscape(s) {
|
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
|
+
function verbatimBody(body, env) {
|
|
166
|
+
return body.split(`\\end{${env}}`).join(`\\end {${env}}`);
|
|
167
|
+
}
|
|
165
168
|
function escapeInlineNonLink(text) {
|
|
166
169
|
let s = texEscape(text);
|
|
167
170
|
s = s.replace(/`([^`]+)`/g, (_m, code) => `\\texttt{${code}}`);
|
|
@@ -199,9 +202,11 @@ function markdownToTex(src) {
|
|
|
199
202
|
i++;
|
|
200
203
|
}
|
|
201
204
|
i++;
|
|
202
|
-
out.push(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
out.push(
|
|
206
|
+
`\\begin{lstlisting}
|
|
207
|
+
${verbatimBody(buf.join("\n"), "lstlisting")}
|
|
208
|
+
\\end{lstlisting}`
|
|
209
|
+
);
|
|
205
210
|
continue;
|
|
206
211
|
}
|
|
207
212
|
if (line2.trim() === "") {
|
|
@@ -407,7 +412,7 @@ function renderCellTex(cell, parse3) {
|
|
|
407
412
|
const cap = cell.id ? `\\textit{${texEscape(cell.id)}}\\\\
|
|
408
413
|
` : "";
|
|
409
414
|
const src = `\\begin{lstlisting}
|
|
410
|
-
${cell.content}
|
|
415
|
+
${verbatimBody(cell.content, "lstlisting")}
|
|
411
416
|
\\end{lstlisting}`;
|
|
412
417
|
let res = "";
|
|
413
418
|
if (cell.error !== void 0)
|
|
@@ -418,7 +423,7 @@ ${cell.content}
|
|
|
418
423
|
res = `
|
|
419
424
|
|
|
420
425
|
\\begin{verbatim}
|
|
421
|
-
${cell.output}
|
|
426
|
+
${verbatimBody(cell.output, "verbatim")}
|
|
422
427
|
\\end{verbatim}`;
|
|
423
428
|
return `${cap}${src}${res}`;
|
|
424
429
|
}
|
|
@@ -435,7 +440,7 @@ ${cell.output}
|
|
|
435
440
|
const cap = cell.id ? `\\textit{${texEscape(cell.id)}}\\\\
|
|
436
441
|
` : "";
|
|
437
442
|
return `${cap}\\begin{verbatim}
|
|
438
|
-
${val}
|
|
443
|
+
${verbatimBody(val, "verbatim")}
|
|
439
444
|
\\end{verbatim}`;
|
|
440
445
|
}
|
|
441
446
|
case "chart": {
|
|
@@ -449,7 +454,7 @@ ${chart}
|
|
|
449
454
|
}
|
|
450
455
|
default:
|
|
451
456
|
return `\\begin{verbatim}
|
|
452
|
-
${cell.content}
|
|
457
|
+
${verbatimBody(cell.content, "verbatim")}
|
|
453
458
|
\\end{verbatim}`;
|
|
454
459
|
}
|
|
455
460
|
}
|
package/dist/index.js
CHANGED
package/dist/markdown.d.ts
CHANGED
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
export declare function markdownToHtml(src: string): string;
|
|
9
9
|
/** Escape LaTeX specials in a single pass (an escape's own backslash/braces are never re-scanned). */
|
|
10
10
|
export declare function texEscape(s: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Keep text inside a `verbatim` or `lstlisting` environment. The body is not escaped
|
|
13
|
+
* (the environment prints it as is), but LaTeX ends the environment at the first exact
|
|
14
|
+
* `\end{<env>}` in it. Each such sequence in the body gets a space after `\end`, so it
|
|
15
|
+
* prints as text and cannot close the environment early.
|
|
16
|
+
*/
|
|
17
|
+
export declare function verbatimBody(body: string, env: 'verbatim' | 'lstlisting'): string;
|
|
11
18
|
/** Minimal Markdown → LaTeX, same subset + safety discipline as markdownToHtml. */
|
|
12
19
|
export declare function markdownToTex(src: string): string;
|
|
13
20
|
//# sourceMappingURL=markdown.d.ts.map
|
package/dist/markdown.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2EH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA+DlD;AAED,sGAAsG;AACtG,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAa3C;AA+BD,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2EH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA+DlD;AAED,sGAAsG;AACtG,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAa3C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,YAAY,GAAG,MAAM,CAEjF;AA+BD,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA+DjD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-workbook",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Scientific workbook runtime for MathTS (.mtsw format)",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,11 +37,12 @@
|
|
|
37
37
|
"@danielsimonjr/mathts-core": "^0.15.0",
|
|
38
38
|
"@danielsimonjr/mathts-expression": "^0.8.0",
|
|
39
39
|
"@danielsimonjr/mathts-functions": "^0.64.1",
|
|
40
|
-
"@danielsimonjr/mathts-plot": "^0.4.
|
|
40
|
+
"@danielsimonjr/mathts-plot": "^0.4.4",
|
|
41
41
|
"yaml": "^2.3.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^26.4.0",
|
|
45
|
+
"@xmldom/xmldom": "^0.9.12",
|
|
45
46
|
"tsup": "^8.0.0",
|
|
46
47
|
"typescript": "^7.0.2",
|
|
47
48
|
"vitest": "^5.0.0"
|