@ai-matrx/print 0.6.1 → 0.7.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 +58 -3
- package/README.md +38 -0
- package/dist/directives.cjs +48 -1
- package/dist/directives.cjs.map +1 -1
- package/dist/directives.d.cts +21 -2
- package/dist/directives.d.ts +21 -2
- package/dist/directives.js +48 -1
- package/dist/directives.js.map +1 -1
- package/dist/document.cjs +2842 -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 +2809 -0
- package/dist/document.js.map +1 -0
- package/dist/markdown.cjs +40 -2
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.js +40 -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
|
@@ -983,7 +983,17 @@ var COMMENT_FORM = /^<!--\s*(?:page[\s_-]?break|new[\s_-]?page)\s*-->$/i;
|
|
|
983
983
|
var LATEX_FORM = /^\\(?:pagebreak|newpage|clearpage)\s*(?:\{\s*\})?$/i;
|
|
984
984
|
var DIV_FORM = /^<div\b([^>]*)>\s*<\/div>$|^<div\b([^>]*)\/>$/i;
|
|
985
985
|
var DIV_BREAK_ATTR = /(?:page-break-(?:after|before)\s*:\s*always|break-(?:after|before)\s*:\s*page|class\s*=\s*["'](?:[^"']*\s)?page-?break(?:\s[^"']*)?["'])/i;
|
|
986
|
+
function indentColumns(line) {
|
|
987
|
+
let cols = 0;
|
|
988
|
+
for (const ch of line) {
|
|
989
|
+
if (ch === " " || ch === "\xA0") cols += 1;
|
|
990
|
+
else if (ch === " ") cols += 4;
|
|
991
|
+
else break;
|
|
992
|
+
}
|
|
993
|
+
return cols;
|
|
994
|
+
}
|
|
986
995
|
function isPageBreakLine(line) {
|
|
996
|
+
if (indentColumns(line) >= 4) return false;
|
|
987
997
|
const t = line.trim();
|
|
988
998
|
if (t.length < 8 || t.length > 200) return false;
|
|
989
999
|
if (COMMENT_FORM.test(t) || LATEX_FORM.test(t)) return true;
|
|
@@ -991,6 +1001,33 @@ function isPageBreakLine(line) {
|
|
|
991
1001
|
if (!div) return false;
|
|
992
1002
|
return DIV_BREAK_ATTR.test(div[1] ?? div[2] ?? "");
|
|
993
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
|
+
}
|
|
994
1031
|
function splitAtPageBreaks(markdown) {
|
|
995
1032
|
const lines = markdown.split(/\r?\n/);
|
|
996
1033
|
const pieces = [];
|
|
@@ -1002,7 +1039,7 @@ function splitAtPageBreaks(markdown) {
|
|
|
1002
1039
|
const marker = fenceMatch[1];
|
|
1003
1040
|
if (fence === null) fence = marker;
|
|
1004
1041
|
else if (marker[0] === fence[0] && marker.length >= fence.length) fence = null;
|
|
1005
|
-
} else if (fence === null &&
|
|
1042
|
+
} else if (fence === null && isBreakLine(line)) {
|
|
1006
1043
|
if (current.join("\n").trim()) pieces.push(current.join("\n"));
|
|
1007
1044
|
current = [];
|
|
1008
1045
|
continue;
|
|
@@ -1229,10 +1266,11 @@ function protectRegions(markdown, g, stash, ctx) {
|
|
|
1229
1266
|
i = j;
|
|
1230
1267
|
continue;
|
|
1231
1268
|
}
|
|
1232
|
-
if (
|
|
1269
|
+
if (isBreakLine(line)) {
|
|
1233
1270
|
out.push(stash.block(PAGE_BREAK_HTML));
|
|
1234
1271
|
continue;
|
|
1235
1272
|
}
|
|
1273
|
+
if (isTocLine(line) || isBibliographyLine(line)) continue;
|
|
1236
1274
|
const open = /^\s*<artifact\b((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>(.*)$/i.exec(line);
|
|
1237
1275
|
if (open) {
|
|
1238
1276
|
const attrs = parseTagAttributes(open[1] ?? "");
|