kordoc 4.18.13 → 4.19.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/README.md +2 -1
- package/dist/{-DC2OO5KO.js → -I3DEUQUC.js} +11 -11
- package/dist/{chunk-K6WSMTVU.cjs → chunk-34RIECIF.cjs} +2 -2
- package/dist/{chunk-K6WSMTVU.cjs.map → chunk-34RIECIF.cjs.map} +1 -1
- package/dist/{chunk-EBXJ45VZ.js → chunk-5B55S4JU.js} +2 -2
- package/dist/{chunk-EBXJ45VZ.js.map → chunk-5B55S4JU.js.map} +1 -1
- package/dist/{chunk-6CQZMVXW.cjs → chunk-5ZSQ2ZIH.cjs} +3 -3
- package/dist/{chunk-6CQZMVXW.cjs.map → chunk-5ZSQ2ZIH.cjs.map} +1 -1
- package/dist/{chunk-GGMIPTM5.cjs → chunk-7TVRQJXI.cjs} +12 -12
- package/dist/{chunk-GGMIPTM5.cjs.map → chunk-7TVRQJXI.cjs.map} +1 -1
- package/dist/{chunk-6AYTYTFY.js → chunk-AAE765MK.js} +3 -3
- package/dist/{chunk-ISC2TH24.js → chunk-AMDDV4CI.js} +2 -2
- package/dist/{chunk-GUH6HYSZ.js → chunk-C4JHZNRL.js} +25 -22
- package/dist/chunk-C4JHZNRL.js.map +1 -0
- package/dist/{chunk-EZSWBHHI.js → chunk-CR4RXHXO.js} +2 -2
- package/dist/{chunk-32ZUIHSY.js → chunk-DEYCTP2S.js} +3 -3
- package/dist/{chunk-SVIOP7PE.js → chunk-DGXGVC4Z.js} +7 -7
- package/dist/{chunk-SVIOP7PE.js.map → chunk-DGXGVC4Z.js.map} +1 -1
- package/dist/{chunk-JPSLMPFI.js → chunk-DH75ZUYF.js} +95 -11
- package/dist/chunk-DH75ZUYF.js.map +1 -0
- package/dist/{chunk-DHEUQXXR.js → chunk-FJE3TMZ7.js} +2 -2
- package/dist/{chunk-ZNY5BRV6.js → chunk-GCYLNOTJ.js} +4 -4
- package/dist/{chunk-GSW7W7AL.js → chunk-GYQVQF2J.js} +7 -4
- package/dist/chunk-GYQVQF2J.js.map +1 -0
- package/dist/{chunk-7LOD4IGO.js → chunk-HFMIAMEO.js} +4 -4
- package/dist/{chunk-XVB3PUPJ.js → chunk-L5KNWOGR.js} +2 -2
- package/dist/chunk-L5KNWOGR.js.map +1 -0
- package/dist/{chunk-RQEDNI4P.cjs → chunk-LLVF6X5W.cjs} +3 -3
- package/dist/{chunk-RQEDNI4P.cjs.map → chunk-LLVF6X5W.cjs.map} +1 -1
- package/dist/{chunk-6FW3AZWN.cjs → chunk-LNU54ZKV.cjs} +117 -33
- package/dist/chunk-LNU54ZKV.cjs.map +1 -0
- package/dist/{chunk-IRN5SDY2.js → chunk-OMJWAJBD.js} +2 -2
- package/dist/{chunk-V7LKQNC4.js → chunk-QHN7N2QA.js} +2 -2
- package/dist/{chunk-INESPVEV.js → chunk-RYKNAYKC.js} +3 -3
- package/dist/{chunk-LKA7Z2NH.js → chunk-UCTD3BXH.js} +2 -2
- package/dist/{chunk-PN5WWW56.js → chunk-UTVNSCEI.js} +2 -2
- package/dist/{chunk-PN5WWW56.js.map → chunk-UTVNSCEI.js.map} +1 -1
- package/dist/{chunk-JWTZ3OVZ.js → chunk-VZSOPECZ.js} +2 -2
- package/dist/{chunk-VDEENOPW.js → chunk-W5XX2GKO.js} +2 -2
- package/dist/{chunk-PHMWSWHJ.js → chunk-XIWGPC3V.js} +2 -2
- package/dist/{chunk-JKHU7HID.js → chunk-XXUXQHUC.js} +95 -11
- package/dist/chunk-XXUXQHUC.js.map +1 -0
- package/dist/{chunk-3FGHQWJP.cjs → chunk-YV4PWWRW.cjs} +22 -22
- package/dist/{chunk-3FGHQWJP.cjs.map → chunk-YV4PWWRW.cjs.map} +1 -1
- package/dist/chunks-JPNLQOVD.js +10 -0
- package/dist/cli.js +39 -28
- package/dist/cli.js.map +1 -1
- package/dist/{formula-YCAO5IVW.js → formula-DUEAYGIG.js} +4 -4
- package/dist/{formula-DAMFHLQO.js → formula-I4MAHCTZ.js} +3 -3
- package/dist/{formula-HJNQGPRC.cjs → formula-L2BKGA4J.cjs} +9 -9
- package/dist/{formula-HJNQGPRC.cjs.map → formula-L2BKGA4J.cjs.map} +1 -1
- package/dist/{image-ocr-VH54SDZ7.js → image-ocr-B32G24XW.js} +6 -6
- package/dist/{image-ocr-PAF76DAW.js → image-ocr-NUL3JKXM.js} +9 -9
- package/dist/{image-ocr-AZ25IOC7.cjs → image-ocr-ZWRJZKYR.cjs} +15 -15
- package/dist/{image-ocr-AZ25IOC7.cjs.map → image-ocr-ZWRJZKYR.cjs.map} +1 -1
- package/dist/index.cjs +669 -663
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +26 -20
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +25 -23
- package/dist/mcp.js.map +1 -1
- package/dist/{model-bundle-53CHDYCG.js → model-bundle-OBIKG4K5.js} +5 -5
- package/dist/{models-UVLAKK3M.js → models-2OZHOPPM.js} +5 -5
- package/dist/{parser-HWAOPQYK.cjs → parser-DMWCXX7A.cjs} +131 -129
- package/dist/parser-DMWCXX7A.cjs.map +1 -0
- package/dist/{parser-I4D3TRGU.js → parser-FDE6GQST.js} +14 -12
- package/dist/{parser-Z6PHB54O.js.map → parser-FDE6GQST.js.map} +1 -1
- package/dist/{parser-Z6PHB54O.js → parser-YW3NMSJE.js} +11 -9
- package/dist/{parser-I4D3TRGU.js.map → parser-YW3NMSJE.js.map} +1 -1
- package/dist/pdf-ocr-7MR56U4P.js +16 -0
- package/dist/pdf-ocr-K2OK7FNQ.cjs +17 -0
- package/dist/{pdf-ocr-HR6CXGTX.cjs.map → pdf-ocr-K2OK7FNQ.cjs.map} +1 -1
- package/dist/pdf-ocr-YHC4X67W.js +20 -0
- package/dist/{profile-io-WHCWCOPW.js → profile-io-6WCU4KHY.js} +3 -3
- package/dist/{rasterize-5DZ3DHGH.js → rasterize-X3I7SWXF.js} +3 -3
- package/dist/{redact-doc-RNJVMFGQ.js → redact-doc-6H7WPUQD.js} +11 -11
- package/dist/{render-NZ6RA6SW.js → render-PBQJGZT3.js} +7 -7
- package/dist/seal-E2E7CFZJ.js +10 -0
- package/dist/{setup-U3EQNK4Z.js → setup-UORJSR3M.js} +3 -3
- package/dist/visual-4GDT5BRH.js +20 -0
- package/dist/{watch-GB2M7XU6.js → watch-S2ZMDDZU.js} +12 -12
- package/package.json +3 -2
- package/dist/chunk-6FW3AZWN.cjs.map +0 -1
- package/dist/chunk-GSW7W7AL.js.map +0 -1
- package/dist/chunk-GUH6HYSZ.js.map +0 -1
- package/dist/chunk-JKHU7HID.js.map +0 -1
- package/dist/chunk-JPSLMPFI.js.map +0 -1
- package/dist/chunk-XVB3PUPJ.js.map +0 -1
- package/dist/chunks-JZW2TXIZ.js +0 -10
- package/dist/parser-HWAOPQYK.cjs.map +0 -1
- package/dist/pdf-ocr-F4ICXO7W.js +0 -20
- package/dist/pdf-ocr-HR6CXGTX.cjs +0 -17
- package/dist/pdf-ocr-JI3K7JIN.js +0 -16
- package/dist/seal-WHJ6O5HT.js +0 -10
- package/dist/visual-JDAS4R43.js +0 -20
- /package/dist/{-DC2OO5KO.js.map → -I3DEUQUC.js.map} +0 -0
- /package/dist/{chunk-6AYTYTFY.js.map → chunk-AAE765MK.js.map} +0 -0
- /package/dist/{chunk-ISC2TH24.js.map → chunk-AMDDV4CI.js.map} +0 -0
- /package/dist/{chunk-EZSWBHHI.js.map → chunk-CR4RXHXO.js.map} +0 -0
- /package/dist/{chunk-32ZUIHSY.js.map → chunk-DEYCTP2S.js.map} +0 -0
- /package/dist/{chunk-DHEUQXXR.js.map → chunk-FJE3TMZ7.js.map} +0 -0
- /package/dist/{chunk-ZNY5BRV6.js.map → chunk-GCYLNOTJ.js.map} +0 -0
- /package/dist/{chunk-7LOD4IGO.js.map → chunk-HFMIAMEO.js.map} +0 -0
- /package/dist/{chunk-IRN5SDY2.js.map → chunk-OMJWAJBD.js.map} +0 -0
- /package/dist/{chunk-V7LKQNC4.js.map → chunk-QHN7N2QA.js.map} +0 -0
- /package/dist/{chunk-INESPVEV.js.map → chunk-RYKNAYKC.js.map} +0 -0
- /package/dist/{chunk-LKA7Z2NH.js.map → chunk-UCTD3BXH.js.map} +0 -0
- /package/dist/{chunk-JWTZ3OVZ.js.map → chunk-VZSOPECZ.js.map} +0 -0
- /package/dist/{chunk-VDEENOPW.js.map → chunk-W5XX2GKO.js.map} +0 -0
- /package/dist/{chunk-PHMWSWHJ.js.map → chunk-XIWGPC3V.js.map} +0 -0
- /package/dist/{chunks-JZW2TXIZ.js.map → chunks-JPNLQOVD.js.map} +0 -0
- /package/dist/{formula-YCAO5IVW.js.map → formula-DUEAYGIG.js.map} +0 -0
- /package/dist/{formula-DAMFHLQO.js.map → formula-I4MAHCTZ.js.map} +0 -0
- /package/dist/{image-ocr-VH54SDZ7.js.map → image-ocr-B32G24XW.js.map} +0 -0
- /package/dist/{image-ocr-PAF76DAW.js.map → image-ocr-NUL3JKXM.js.map} +0 -0
- /package/dist/{model-bundle-53CHDYCG.js.map → model-bundle-OBIKG4K5.js.map} +0 -0
- /package/dist/{models-UVLAKK3M.js.map → models-2OZHOPPM.js.map} +0 -0
- /package/dist/{pdf-ocr-F4ICXO7W.js.map → pdf-ocr-7MR56U4P.js.map} +0 -0
- /package/dist/{pdf-ocr-JI3K7JIN.js.map → pdf-ocr-YHC4X67W.js.map} +0 -0
- /package/dist/{profile-io-WHCWCOPW.js.map → profile-io-6WCU4KHY.js.map} +0 -0
- /package/dist/{rasterize-5DZ3DHGH.js.map → rasterize-X3I7SWXF.js.map} +0 -0
- /package/dist/{redact-doc-RNJVMFGQ.js.map → redact-doc-6H7WPUQD.js.map} +0 -0
- /package/dist/{render-NZ6RA6SW.js.map → render-PBQJGZT3.js.map} +0 -0
- /package/dist/{seal-WHJ6O5HT.js.map → seal-E2E7CFZJ.js.map} +0 -0
- /package/dist/{setup-U3EQNK4Z.js.map → setup-UORJSR3M.js.map} +0 -0
- /package/dist/{visual-JDAS4R43.js.map → visual-4GDT5BRH.js.map} +0 -0
- /package/dist/{watch-GB2M7XU6.js.map → watch-S2ZMDDZU.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk34RIECIFcjs = require('./chunk-34RIECIF.cjs');
|
|
5
5
|
|
|
6
6
|
// src/script-tags.ts
|
|
7
7
|
var LITERAL_TAG = /<(?=\/?(?:u|sup|sub)>)/g;
|
|
@@ -763,7 +763,27 @@ function spansToMarkdown(spans) {
|
|
|
763
763
|
}
|
|
764
764
|
return out;
|
|
765
765
|
}
|
|
766
|
-
function
|
|
766
|
+
function assignTableIds(blocks) {
|
|
767
|
+
const tables = [];
|
|
768
|
+
const walk = (bs) => {
|
|
769
|
+
for (const b of _nullishCoalesce(bs, () => ( []))) {
|
|
770
|
+
if (b.type !== "table" || !b.table) continue;
|
|
771
|
+
walk(b.table.captionBlocks);
|
|
772
|
+
tables.push(b.table);
|
|
773
|
+
for (const row of b.table.cells) for (const cell of row) walk(cell.blocks);
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
walk(blocks);
|
|
777
|
+
let next = 1;
|
|
778
|
+
for (const t of tables) {
|
|
779
|
+
const n = t.markdownId ? Number(t.markdownId.slice(1)) : 0;
|
|
780
|
+
if (n >= next) next = n + 1;
|
|
781
|
+
}
|
|
782
|
+
for (const t of tables) if (!t.markdownId) t.markdownId = `t${next++}`;
|
|
783
|
+
}
|
|
784
|
+
function blocksToMarkdown(blocks, options) {
|
|
785
|
+
const gfm = _optionalChain([options, 'optionalAccess', _26 => _26.tableFormat]) === "gfm";
|
|
786
|
+
if (gfm) assignTableIds(blocks);
|
|
767
787
|
const lines = [];
|
|
768
788
|
for (let i = 0; i < blocks.length; i++) {
|
|
769
789
|
const block = blocks[i];
|
|
@@ -803,7 +823,7 @@ function blocksToMarkdown(blocks) {
|
|
|
803
823
|
if (lines.length && lines[lines.length - 1] !== "") lines.push("");
|
|
804
824
|
if (/^\[별표\s*\d+/.test(text)) {
|
|
805
825
|
const nextBlock = blocks[i + 1];
|
|
806
|
-
if (_optionalChain([nextBlock, 'optionalAccess',
|
|
826
|
+
if (_optionalChain([nextBlock, 'optionalAccess', _27 => _27.type]) === "paragraph" && nextBlock.text && /관련\)?$/.test(nextBlock.text)) {
|
|
807
827
|
lines.push("", `## ${escapeGfm(text)} ${escapeGfm(nextBlock.text)}`, "");
|
|
808
828
|
i++;
|
|
809
829
|
} else {
|
|
@@ -816,10 +836,10 @@ function blocksToMarkdown(blocks) {
|
|
|
816
836
|
continue;
|
|
817
837
|
}
|
|
818
838
|
const listIndent = block.listDepth ? " ".repeat(block.listDepth) : "";
|
|
819
|
-
if (_optionalChain([block, 'access',
|
|
839
|
+
if (_optionalChain([block, 'access', _28 => _28.spans, 'optionalAccess', _29 => _29.length])) {
|
|
820
840
|
let rendered = spansToMarkdown(block.spans);
|
|
821
841
|
if (block.href) {
|
|
822
|
-
const href =
|
|
842
|
+
const href = _chunk34RIECIFcjs.sanitizeHref.call(void 0, block.href);
|
|
823
843
|
if (href) rendered = `[${rendered}](${href})`;
|
|
824
844
|
}
|
|
825
845
|
if (block.footnoteText) rendered += ` (\uC8FC: ${block.footnoteText})`;
|
|
@@ -827,7 +847,7 @@ function blocksToMarkdown(blocks) {
|
|
|
827
847
|
continue;
|
|
828
848
|
}
|
|
829
849
|
if (block.href) {
|
|
830
|
-
const href =
|
|
850
|
+
const href = _chunk34RIECIFcjs.sanitizeHref.call(void 0, block.href);
|
|
831
851
|
if (href) text = `[${text}](${href})`;
|
|
832
852
|
}
|
|
833
853
|
if (block.footnoteText) {
|
|
@@ -838,8 +858,8 @@ function blocksToMarkdown(blocks) {
|
|
|
838
858
|
if (lines.length > 0 && lines[lines.length - 1] !== "") {
|
|
839
859
|
lines.push("");
|
|
840
860
|
}
|
|
841
|
-
lines.push(...captionToMarkdown(block.table));
|
|
842
|
-
const tableMd = tableToMarkdown(block.table);
|
|
861
|
+
lines.push(...captionToMarkdown(block.table, gfm));
|
|
862
|
+
const tableMd = tableToMarkdown(block.table, gfm);
|
|
843
863
|
if (tableMd) {
|
|
844
864
|
lines.push(tableMd);
|
|
845
865
|
lines.push("");
|
|
@@ -848,12 +868,12 @@ function blocksToMarkdown(blocks) {
|
|
|
848
868
|
}
|
|
849
869
|
return lines.join("\n").trim();
|
|
850
870
|
}
|
|
851
|
-
function captionToMarkdown(table) {
|
|
852
|
-
if (_optionalChain([table, 'access',
|
|
871
|
+
function captionToMarkdown(table, gfm = false) {
|
|
872
|
+
if (_optionalChain([table, 'access', _30 => _30.captionBlocks, 'optionalAccess', _31 => _31.length])) {
|
|
853
873
|
return table.captionBlocks.flatMap((b) => {
|
|
854
874
|
if (b.type === "table" && b.table) {
|
|
855
|
-
const md = tableToMarkdown(b.table);
|
|
856
|
-
return [...captionToMarkdown(b.table), ...md ? [md, ""] : []];
|
|
875
|
+
const md = tableToMarkdown(b.table, gfm);
|
|
876
|
+
return [...captionToMarkdown(b.table, gfm), ...md ? [md, ""] : []];
|
|
857
877
|
}
|
|
858
878
|
if (b.type === "image" && b.text) return [blocksToMarkdown([b]), ""];
|
|
859
879
|
const t = (sanitizeText(visibleText(b)) + noteSuffix(b)).trim();
|
|
@@ -864,7 +884,7 @@ function captionToMarkdown(table) {
|
|
|
864
884
|
return caption ? [`**${escapeGfm(caption)}**`, ""] : [];
|
|
865
885
|
}
|
|
866
886
|
function captionToHtml(table) {
|
|
867
|
-
if (_optionalChain([table, 'access',
|
|
887
|
+
if (_optionalChain([table, 'access', _32 => _32.captionBlocks, 'optionalAccess', _33 => _33.length])) return cellInnerHtml({ text: "", colSpan: 1, rowSpan: 1, blocks: table.captionBlocks });
|
|
868
888
|
const cap = table.caption ? sanitizeText(table.caption) : "";
|
|
869
889
|
return cap ? escapeHtmlCellText(cap).replace(/\n/g, "<br>") : "";
|
|
870
890
|
}
|
|
@@ -876,10 +896,18 @@ function hasMergedCells(table) {
|
|
|
876
896
|
}
|
|
877
897
|
return false;
|
|
878
898
|
}
|
|
899
|
+
function hasNestedTables(table) {
|
|
900
|
+
for (const row of table.cells) {
|
|
901
|
+
for (const cell of row) {
|
|
902
|
+
if (_optionalChain([cell, 'access', _34 => _34.blocks, 'optionalAccess', _35 => _35.some, 'call', _36 => _36((b) => b.type === "table" && b.table)])) return true;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
return false;
|
|
906
|
+
}
|
|
879
907
|
function hasStructuredCellContent(table) {
|
|
880
908
|
for (const row of table.cells) {
|
|
881
909
|
for (const cell of row) {
|
|
882
|
-
if (_optionalChain([cell, 'access',
|
|
910
|
+
if (_optionalChain([cell, 'access', _37 => _37.blocks, 'optionalAccess', _38 => _38.some, 'call', _39 => _39((b) => b.type === "table" && b.table || b.type === "separator")])) return true;
|
|
883
911
|
}
|
|
884
912
|
}
|
|
885
913
|
return false;
|
|
@@ -888,19 +916,19 @@ function noteSuffix(b) {
|
|
|
888
916
|
return b.footnoteText ? ` (\uC8FC: ${b.footnoteText})` : "";
|
|
889
917
|
}
|
|
890
918
|
function visibleText(b) {
|
|
891
|
-
return _optionalChain([b, 'access',
|
|
919
|
+
return _optionalChain([b, 'access', _40 => _40.spans, 'optionalAccess', _41 => _41.some, 'call', _42 => _42((s) => s.placeholder)]) ? b.spans.filter((s) => !s.placeholder).map((s) => s.text).join("") : _nullishCoalesce(b.text, () => ( ""));
|
|
892
920
|
}
|
|
893
921
|
function escapeHtmlCellText(text) {
|
|
894
|
-
return
|
|
922
|
+
return _chunk34RIECIFcjs.escapeHtml.call(void 0, text).replace(/(\\)?<(\/?)(u|sup|sub)>/g, (_, esc, sl, tag) => esc ? `<${sl}${tag}>` : `<${sl}${tag}>`);
|
|
895
923
|
}
|
|
896
924
|
function cellInnerHtml(cell) {
|
|
897
|
-
if (_optionalChain([cell, 'access',
|
|
925
|
+
if (_optionalChain([cell, 'access', _43 => _43.blocks, 'optionalAccess', _44 => _44.length])) {
|
|
898
926
|
return cell.blocks.map((b) => {
|
|
899
927
|
if (b.type === "table" && b.table) {
|
|
900
928
|
const cap = captionToHtml(b.table);
|
|
901
929
|
return (cap ? cap + "<br>" : "") + tableToHtml(b.table);
|
|
902
930
|
}
|
|
903
|
-
if (b.type === "image" && b.text) return `<img src="${
|
|
931
|
+
if (b.type === "image" && b.text) return `<img src="${_chunk34RIECIFcjs.escapeHtml.call(void 0, b.text, true)}" alt="image">`;
|
|
904
932
|
const t = (sanitizeText(visibleText(b)) + noteSuffix(b)).trim();
|
|
905
933
|
return t ? escapeHtmlCellText(t).replace(/\n/g, "<br>") : "";
|
|
906
934
|
}).filter(Boolean).join("<br>");
|
|
@@ -916,7 +944,7 @@ function tableToHtml(table) {
|
|
|
916
944
|
const rowHtml = [];
|
|
917
945
|
for (let c = 0; c < numCols; c++) {
|
|
918
946
|
if (skip.has(`${r},${c}`)) continue;
|
|
919
|
-
const cell = _optionalChain([cells, 'access',
|
|
947
|
+
const cell = _optionalChain([cells, 'access', _45 => _45[r], 'optionalAccess', _46 => _46[c]]);
|
|
920
948
|
if (!cell) continue;
|
|
921
949
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
922
950
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -937,15 +965,62 @@ function tableToHtml(table) {
|
|
|
937
965
|
return lines.join("\n");
|
|
938
966
|
}
|
|
939
967
|
function hasInlineCellBlocks(cell) {
|
|
940
|
-
return !!_optionalChain([cell, 'access',
|
|
968
|
+
return !!_optionalChain([cell, 'access', _47 => _47.blocks, 'optionalAccess', _48 => _48.some, 'call', _49 => _49((b) => _optionalChain([b, 'access', _50 => _50.spans, 'optionalAccess', _51 => _51.length]) || b.footnoteText || b.type === "image" && b.text)]);
|
|
969
|
+
}
|
|
970
|
+
function cellBlockToMarkdown(b) {
|
|
971
|
+
return b.type === "image" && b.text ? `` : _optionalChain([b, 'access', _52 => _52.spans, 'optionalAccess', _53 => _53.length]) ? spansToMarkdown(b.spans) + escapeGfm(noteSuffix(b)) : escapeGfm(sanitizeText(_nullishCoalesce(b.text, () => ( ""))) + noteSuffix(b));
|
|
941
972
|
}
|
|
942
973
|
function cellToMarkdown(cell, separator) {
|
|
943
974
|
if (!hasInlineCellBlocks(cell)) return escapeGfm(sanitizeText(cell.text));
|
|
944
|
-
return cell.blocks.map(
|
|
975
|
+
return cell.blocks.map(cellBlockToMarkdown).filter(Boolean).join(separator);
|
|
945
976
|
}
|
|
946
|
-
function
|
|
977
|
+
function tableToGfm(table) {
|
|
978
|
+
if (table.rows === 0 || table.cols === 0) return "";
|
|
979
|
+
const nested = [];
|
|
980
|
+
const markerless = /* @__PURE__ */ new Map();
|
|
981
|
+
const md = pipeTable(table, (cell) => gfmCellText(cell, table.markdownId, nested, markerless), (cell, text) => _nullishCoalesce(markerless.get(cell), () => ( text)));
|
|
982
|
+
if (!md) return "";
|
|
983
|
+
const out = [md];
|
|
984
|
+
for (const child of nested) {
|
|
985
|
+
out.push("", ...captionToMarkdown(child.table, true), `<!-- <table id="${child.table.markdownId}" parent_id="${table.markdownId}" /> -->`, child.md);
|
|
986
|
+
}
|
|
987
|
+
return out.join("\n");
|
|
988
|
+
}
|
|
989
|
+
function gfmCellText(cell, parentId, nested, markerless) {
|
|
990
|
+
if (!_optionalChain([cell, 'access', _54 => _54.blocks, 'optionalAccess', _55 => _55.some, 'call', _56 => _56((b) => b.type === "table" && b.table || b.type === "separator")])) return cellToMarkdown(cell, "<br>");
|
|
991
|
+
let out = "";
|
|
992
|
+
let text = "";
|
|
993
|
+
let hasMarker = false;
|
|
994
|
+
let prevMarker = false;
|
|
995
|
+
for (const b of cell.blocks) {
|
|
996
|
+
if (b.type === "separator") continue;
|
|
997
|
+
let part;
|
|
998
|
+
const marker = b.type === "table" && !!b.table;
|
|
999
|
+
if (marker) {
|
|
1000
|
+
const md = tableToGfm(b.table);
|
|
1001
|
+
if (!md) continue;
|
|
1002
|
+
nested.push({ table: b.table, md });
|
|
1003
|
+
part = `<!-- <table parent_id="${parentId}" child_id="${b.table.markdownId}" /> -->`;
|
|
1004
|
+
} else {
|
|
1005
|
+
part = cellBlockToMarkdown(b);
|
|
1006
|
+
if (!part) continue;
|
|
1007
|
+
text += text ? "<br>" + part : part;
|
|
1008
|
+
}
|
|
1009
|
+
out += out ? (marker || prevMarker ? " " : "<br>") + part : part;
|
|
1010
|
+
prevMarker = marker;
|
|
1011
|
+
hasMarker ||= marker;
|
|
1012
|
+
}
|
|
1013
|
+
if (hasMarker) markerless.set(cell, text);
|
|
1014
|
+
return out;
|
|
1015
|
+
}
|
|
1016
|
+
function tableToMarkdown(table, gfm = false) {
|
|
947
1017
|
if (table.rows === 0 || table.cols === 0) return "";
|
|
948
1018
|
const { cells, rows: numRows, cols: numCols } = table;
|
|
1019
|
+
if (gfm && (hasStructuredCellContent(table) || table.renderAsTable || hasMergedCells(table))) {
|
|
1020
|
+
const md = tableToGfm(table);
|
|
1021
|
+
return md && hasNestedTables(table) ? `<!-- <table id="${table.markdownId}" /> -->
|
|
1022
|
+
${md}` : md;
|
|
1023
|
+
}
|
|
949
1024
|
if (hasStructuredCellContent(table)) return tableToHtml(table);
|
|
950
1025
|
if (table.renderAsTable) return tableToHtml(table);
|
|
951
1026
|
if (hasMergedCells(table)) return tableToHtml(table);
|
|
@@ -966,19 +1041,27 @@ function tableToMarkdown(table) {
|
|
|
966
1041
|
if (numCols === 1 && numRows >= 2) {
|
|
967
1042
|
return cells.map((row) => escapeGfm(sanitizeText(row[0].text)).split("\n").map((l) => l.trim()).filter(Boolean).join("\n")).filter(Boolean).join("\n");
|
|
968
1043
|
}
|
|
1044
|
+
return pipeTable(table, (cell) => cellToMarkdown(cell, "<br>"));
|
|
1045
|
+
}
|
|
1046
|
+
function pipeTable(table, cellText, rowSpanFill) {
|
|
1047
|
+
const { cells, rows: numRows, cols: numCols } = table;
|
|
969
1048
|
const display = Array.from({ length: numRows }, () => Array(numCols).fill(""));
|
|
970
1049
|
const skip = /* @__PURE__ */ new Set();
|
|
971
1050
|
for (let r = 0; r < numRows; r++) {
|
|
972
1051
|
for (let c = 0; c < numCols; c++) {
|
|
973
1052
|
if (skip.has(`${r},${c}`)) continue;
|
|
974
|
-
const cell = _optionalChain([cells, 'access',
|
|
1053
|
+
const cell = _optionalChain([cells, 'access', _57 => _57[r], 'optionalAccess', _58 => _58[c]]);
|
|
975
1054
|
if (!cell) continue;
|
|
976
|
-
|
|
1055
|
+
const cellMd = (text2) => text2.replace(/\r\n|\r|\n/g, "<br>").replace(/(?<!\\)\|/g, "\\|");
|
|
1056
|
+
const text = cellText(cell);
|
|
1057
|
+
display[r][c] = cellMd(text);
|
|
1058
|
+
const fill = rowSpanFill ? cellMd(rowSpanFill(cell, text)) : "";
|
|
977
1059
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
978
1060
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
979
1061
|
if (dr === 0 && dc === 0) continue;
|
|
980
1062
|
if (r + dr < numRows && c + dc < numCols) {
|
|
981
1063
|
skip.add(`${r + dr},${c + dc}`);
|
|
1064
|
+
if (dc === 0) display[r + dr][c] = fill;
|
|
982
1065
|
}
|
|
983
1066
|
}
|
|
984
1067
|
}
|
|
@@ -1010,7 +1093,7 @@ function anchorsOf(t) {
|
|
|
1010
1093
|
const covered = /* @__PURE__ */ new Set();
|
|
1011
1094
|
for (let r = 0; r < t.rows; r++) for (let c = 0; c < t.cols; c++) {
|
|
1012
1095
|
if (covered.has(r * t.cols + c)) continue;
|
|
1013
|
-
const cell = _optionalChain([t, 'access',
|
|
1096
|
+
const cell = _optionalChain([t, 'access', _59 => _59.cells, 'access', _60 => _60[r], 'optionalAccess', _61 => _61[c]]);
|
|
1014
1097
|
if (!cell) continue;
|
|
1015
1098
|
const rs = Math.max(1, Math.min(cell.rowSpan, t.rows - r)), cs = Math.max(1, Math.min(cell.colSpan, t.cols - c));
|
|
1016
1099
|
for (let dr = 0; dr < rs; dr++) for (let dc = 0; dc < cs; dc++) covered.add((r + dr) * t.cols + c + dc);
|
|
@@ -1039,7 +1122,7 @@ function toTex(s) {
|
|
|
1039
1122
|
}
|
|
1040
1123
|
function fractionPart(cell) {
|
|
1041
1124
|
const t = cell.text.trim();
|
|
1042
|
-
return !!t && !t.includes("\n") && !_optionalChain([cell, 'access',
|
|
1125
|
+
return !!t && !t.includes("\n") && !_optionalChain([cell, 'access', _62 => _62.blocks, 'optionalAccess', _63 => _63.length]) && t.replace(/<\/?(?:u|sup|sub)>/g, "").length <= FRACTION_MAX_CHARS && !/(?<!\\)\$/.test(t);
|
|
1043
1126
|
}
|
|
1044
1127
|
function mergeFractions(t, anchors, H, V) {
|
|
1045
1128
|
const at = /* @__PURE__ */ new Map();
|
|
@@ -1074,7 +1157,7 @@ function bandTable(t, anchors, V, H, r0, r1, keepEmptyCols) {
|
|
|
1074
1157
|
let list = anchors.filter((a) => a.r >= r0 && a.r <= r1).map((a) => ({ ...a, rs: Math.min(a.rs, r1 - a.r + 1) }));
|
|
1075
1158
|
const blank = (a) => {
|
|
1076
1159
|
if (CONTENT_CELLS.has(a.cell)) return false;
|
|
1077
|
-
if (!_optionalChain([a, 'access',
|
|
1160
|
+
if (!_optionalChain([a, 'access', _64 => _64.cell, 'access', _65 => _65.blocks, 'optionalAccess', _66 => _66.length])) return !a.cell.text.trim();
|
|
1078
1161
|
return a.cell.blocks.every((b) => (b.type === "paragraph" || b.type === "heading") && !visibleText(b).trim() && !b.footnoteText);
|
|
1079
1162
|
};
|
|
1080
1163
|
let lo = Infinity, hi = -Infinity;
|
|
@@ -1138,7 +1221,7 @@ function textRow(row, out, pageNumber, keepEmptyCols) {
|
|
|
1138
1221
|
parts.length = 0;
|
|
1139
1222
|
};
|
|
1140
1223
|
for (const a of row) {
|
|
1141
|
-
if (_optionalChain([a, 'access',
|
|
1224
|
+
if (_optionalChain([a, 'access', _67 => _67.cell, 'access', _68 => _68.blocks, 'optionalAccess', _69 => _69.length])) {
|
|
1142
1225
|
flush();
|
|
1143
1226
|
out.push(...unframeLayoutTables(a.cell.blocks, keepEmptyCols));
|
|
1144
1227
|
continue;
|
|
@@ -1172,7 +1255,7 @@ function unframeTable(t, pageNumber, keepEmptyCols) {
|
|
|
1172
1255
|
}, pageNumber }];
|
|
1173
1256
|
}
|
|
1174
1257
|
const out = [];
|
|
1175
|
-
if (_optionalChain([t, 'access',
|
|
1258
|
+
if (_optionalChain([t, 'access', _70 => _70.captionBlocks, 'optionalAccess', _71 => _71.length])) out.push(...t.captionBlocks);
|
|
1176
1259
|
else if (t.caption) out.push({ type: "paragraph", text: t.caption, pageNumber });
|
|
1177
1260
|
for (let r = 0; r < t.rows; ) {
|
|
1178
1261
|
if (ruled[r]) {
|
|
@@ -1195,12 +1278,12 @@ function unframeLayoutTables(blocks, keepEmptyCols = false) {
|
|
|
1195
1278
|
out.push(b);
|
|
1196
1279
|
continue;
|
|
1197
1280
|
}
|
|
1198
|
-
if (_optionalChain([b, 'access',
|
|
1281
|
+
if (_optionalChain([b, 'access', _72 => _72.table, 'access', _73 => _73.captionBlocks, 'optionalAccess', _74 => _74.length])) b.table.captionBlocks = unframeLayoutTables(b.table.captionBlocks, keepEmptyCols);
|
|
1199
1282
|
const flat = unframeTable(b.table, b.pageNumber, keepEmptyCols);
|
|
1200
1283
|
const kept = _nullishCoalesce(flat, () => ( [b]));
|
|
1201
1284
|
for (const k of kept) {
|
|
1202
1285
|
if (k.type === "table" && k.table) {
|
|
1203
|
-
for (const row of k.table.cells) for (const cell of row) if (_optionalChain([cell, 'access',
|
|
1286
|
+
for (const row of k.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _75 => _75.blocks, 'optionalAccess', _76 => _76.length])) cell.blocks = unframeLayoutTables(cell.blocks, keepEmptyCols);
|
|
1204
1287
|
}
|
|
1205
1288
|
out.push(k);
|
|
1206
1289
|
}
|
|
@@ -1241,5 +1324,6 @@ var HEADING_RATIO_H3 = 1.15;
|
|
|
1241
1324
|
|
|
1242
1325
|
|
|
1243
1326
|
|
|
1244
|
-
|
|
1245
|
-
|
|
1327
|
+
|
|
1328
|
+
exports.escapeLiteralTags = escapeLiteralTags; exports.wrapScript = wrapScript; exports.tidyScriptTags = tidyScriptTags; exports.plainScripts = plainScripts; exports.stripScriptTags = stripScriptTags; exports.WINGDINGS = WINGDINGS; exports.mapPuaText = mapPuaText; exports.MAX_COLS = MAX_COLS; exports.MAX_ROWS = MAX_ROWS; exports.MAX_TABLE_CELLS = MAX_TABLE_CELLS; exports.buildTable = buildTable; exports.convertTableToText = convertTableToText; exports.escapeGfm = escapeGfm; exports.escapeLiteralDollar = escapeLiteralDollar; exports.markNonLayoutTable = markNonLayoutTable; exports.flattenLayoutTables = flattenLayoutTables; exports.dedupeRunningHeaders = dedupeRunningHeaders; exports.assignTableIds = assignTableIds; exports.blocksToMarkdown = blocksToMarkdown; exports.hasStructuredCellContent = hasStructuredCellContent; exports.noteSuffix = noteSuffix; exports.escapeHtmlCellText = escapeHtmlCellText; exports.CELL_EDGES = CELL_EDGES; exports.CONTENT_CELLS = CONTENT_CELLS; exports.unframeLayoutTables = unframeLayoutTables; exports.HEADING_RATIO_H1 = HEADING_RATIO_H1; exports.HEADING_RATIO_H2 = HEADING_RATIO_H2; exports.HEADING_RATIO_H3 = HEADING_RATIO_H3;
|
|
1329
|
+
//# sourceMappingURL=chunk-LNU54ZKV.cjs.map
|