@ai-matrx/print 0.6.2 → 0.7.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 +62 -0
- package/README.md +38 -0
- package/dist/directives.cjs +38 -1
- package/dist/directives.cjs.map +1 -1
- package/dist/directives.d.cts +17 -1
- package/dist/directives.d.ts +17 -1
- package/dist/directives.js +38 -1
- package/dist/directives.js.map +1 -1
- package/dist/document.cjs +2860 -0
- package/dist/document.cjs.map +1 -0
- package/dist/document.d.cts +490 -0
- package/dist/document.d.ts +490 -0
- package/dist/document.js +2827 -0
- package/dist/document.js.map +1 -0
- package/dist/markdown.cjs +30 -2
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.js +30 -2
- package/dist/markdown.js.map +1 -1
- package/dist/pdf.cjs.map +1 -1
- package/dist/pdf.js.map +1 -1
- package/dist/react.cjs +117 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +24 -1
- package/dist/react.d.ts +24 -1
- package/dist/react.js +117 -0
- package/dist/react.js.map +1 -1
- package/package.json +29 -3
package/dist/markdown.js
CHANGED
|
@@ -1001,6 +1001,33 @@ function isPageBreakLine(line) {
|
|
|
1001
1001
|
if (!div) return false;
|
|
1002
1002
|
return DIV_BREAK_ATTR.test(div[1] ?? div[2] ?? "");
|
|
1003
1003
|
}
|
|
1004
|
+
var SECTION_FORM = /^<!--\s*section(?:[\s_-]?break)?\b\s*:?\s*([^>]*?)\s*-->$/i;
|
|
1005
|
+
function parseSectionBreakLine(line) {
|
|
1006
|
+
if (indentColumns(line) >= 4) return null;
|
|
1007
|
+
const m = SECTION_FORM.exec(line.trim());
|
|
1008
|
+
if (!m) return null;
|
|
1009
|
+
const words = (m[1] ?? "").toLowerCase();
|
|
1010
|
+
const out = {};
|
|
1011
|
+
if (/\blandscape\b/.test(words)) out.orientation = "landscape";
|
|
1012
|
+
else if (/\bportrait\b/.test(words)) out.orientation = "portrait";
|
|
1013
|
+
const cols = /\b(?:columns?|cols?)\s*[=:]\s*(\d)\b/.exec(words) ?? /\b(\d)\s*[-\s]?columns?\b/.exec(words);
|
|
1014
|
+
if (cols) {
|
|
1015
|
+
const n = Math.min(3, Math.max(1, Number(cols[1])));
|
|
1016
|
+
out.columns = n;
|
|
1017
|
+
}
|
|
1018
|
+
return out;
|
|
1019
|
+
}
|
|
1020
|
+
var TOC_FORM = /^(?:\[\[\s*toc\s*\]\]|\[toc\]|\$\{toc\}|<!--\s*toc\s*-->|\\tableofcontents)$/i;
|
|
1021
|
+
var BIBLIOGRAPHY_FORM = /^(?:\[\[\s*(?:bibliography|references)\s*\]\]|<!--\s*(?:bibliography|references)\s*-->|\\printbibliography|\\bibliography\{[^}]*\})$/i;
|
|
1022
|
+
function isTocLine(line) {
|
|
1023
|
+
return indentColumns(line) < 4 && TOC_FORM.test(line.trim());
|
|
1024
|
+
}
|
|
1025
|
+
function isBibliographyLine(line) {
|
|
1026
|
+
return indentColumns(line) < 4 && BIBLIOGRAPHY_FORM.test(line.trim());
|
|
1027
|
+
}
|
|
1028
|
+
function isBreakLine(line) {
|
|
1029
|
+
return isPageBreakLine(line) || parseSectionBreakLine(line) !== null;
|
|
1030
|
+
}
|
|
1004
1031
|
function splitAtPageBreaks(markdown) {
|
|
1005
1032
|
const lines = markdown.split(/\r?\n/);
|
|
1006
1033
|
const pieces = [];
|
|
@@ -1012,7 +1039,7 @@ function splitAtPageBreaks(markdown) {
|
|
|
1012
1039
|
const marker = fenceMatch[1];
|
|
1013
1040
|
if (fence === null) fence = marker;
|
|
1014
1041
|
else if (marker[0] === fence[0] && marker.length >= fence.length) fence = null;
|
|
1015
|
-
} else if (fence === null &&
|
|
1042
|
+
} else if (fence === null && isBreakLine(line)) {
|
|
1016
1043
|
if (current.join("\n").trim()) pieces.push(current.join("\n"));
|
|
1017
1044
|
current = [];
|
|
1018
1045
|
continue;
|
|
@@ -1239,10 +1266,11 @@ function protectRegions(markdown, g, stash, ctx) {
|
|
|
1239
1266
|
i = j;
|
|
1240
1267
|
continue;
|
|
1241
1268
|
}
|
|
1242
|
-
if (
|
|
1269
|
+
if (isBreakLine(line)) {
|
|
1243
1270
|
out.push(stash.block(PAGE_BREAK_HTML));
|
|
1244
1271
|
continue;
|
|
1245
1272
|
}
|
|
1273
|
+
if (isTocLine(line) || isBibliographyLine(line)) continue;
|
|
1246
1274
|
const open = /^\s*<artifact\b((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>(.*)$/i.exec(line);
|
|
1247
1275
|
if (open) {
|
|
1248
1276
|
const attrs = parseTagAttributes(open[1] ?? "");
|