kordoc 4.18.13 → 4.19.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/README.md +3 -1
- package/dist/{-DC2OO5KO.js → -LYUUVVQF.js} +11 -11
- package/dist/{chunk-ISC2TH24.js → chunk-4WTJS6ES.js} +2 -2
- package/dist/{chunk-SVIOP7PE.js → chunk-5AZQEMMG.js} +7 -7
- package/dist/{chunk-SVIOP7PE.js.map → chunk-5AZQEMMG.js.map} +1 -1
- package/dist/{chunk-GUH6HYSZ.js → chunk-6KOQPPLX.js} +25 -22
- package/dist/chunk-6KOQPPLX.js.map +1 -0
- package/dist/{chunk-PN5WWW56.js → chunk-7L5GY54Q.js} +2 -2
- package/dist/{chunk-PN5WWW56.js.map → chunk-7L5GY54Q.js.map} +1 -1
- package/dist/{chunk-PHMWSWHJ.js → chunk-7XRI4FL4.js} +2 -2
- package/dist/{chunk-32ZUIHSY.js → chunk-ADBES5QJ.js} +3 -3
- package/dist/{chunk-JWTZ3OVZ.js → chunk-BDTWXJNM.js} +2 -2
- package/dist/{chunk-INESPVEV.js → chunk-CL3CJ7X5.js} +3 -3
- package/dist/{chunk-VDEENOPW.js → chunk-DQHDI567.js} +2 -2
- package/dist/{chunk-ZNY5BRV6.js → chunk-FEGRQA3Q.js} +4 -4
- package/dist/{chunk-3FGHQWJP.cjs → chunk-FNX3ZAYB.cjs} +22 -22
- package/dist/{chunk-3FGHQWJP.cjs.map → chunk-FNX3ZAYB.cjs.map} +1 -1
- package/dist/{chunk-GGMIPTM5.cjs → chunk-GPNPYBXJ.cjs} +12 -12
- package/dist/{chunk-GGMIPTM5.cjs.map → chunk-GPNPYBXJ.cjs.map} +1 -1
- package/dist/{chunk-6CQZMVXW.cjs → chunk-HMJXB7ZE.cjs} +3 -3
- package/dist/{chunk-6CQZMVXW.cjs.map → chunk-HMJXB7ZE.cjs.map} +1 -1
- package/dist/{chunk-IRN5SDY2.js → chunk-JA5B4NPF.js} +2 -2
- package/dist/{chunk-GSW7W7AL.js → chunk-JNIJPP4B.js} +7 -4
- package/dist/chunk-JNIJPP4B.js.map +1 -0
- package/dist/{chunk-EZSWBHHI.js → chunk-KYFP5LDC.js} +2 -2
- package/dist/{chunk-XVB3PUPJ.js → chunk-L5N5UQBP.js} +10 -4
- package/dist/chunk-L5N5UQBP.js.map +1 -0
- package/dist/{chunk-6AYTYTFY.js → chunk-MSUGYK6A.js} +3 -3
- package/dist/{chunk-K6WSMTVU.cjs → chunk-RHMIEEAZ.cjs} +2 -2
- package/dist/{chunk-K6WSMTVU.cjs.map → chunk-RHMIEEAZ.cjs.map} +1 -1
- package/dist/{chunk-JKHU7HID.js → chunk-TRUR4RUJ.js} +95 -11
- package/dist/chunk-TRUR4RUJ.js.map +1 -0
- package/dist/{chunk-DHEUQXXR.js → chunk-UAAYIEIK.js} +2 -2
- package/dist/{chunk-RQEDNI4P.cjs → chunk-UOXOYZU4.cjs} +3 -3
- package/dist/{chunk-RQEDNI4P.cjs.map → chunk-UOXOYZU4.cjs.map} +1 -1
- package/dist/{chunk-6FW3AZWN.cjs → chunk-W5NXOMCD.cjs} +125 -35
- package/dist/chunk-W5NXOMCD.cjs.map +1 -0
- package/dist/{chunk-V7LKQNC4.js → chunk-X6ME7YYS.js} +2 -2
- package/dist/{chunk-LKA7Z2NH.js → chunk-XFZMRCGJ.js} +2 -2
- package/dist/{chunk-JPSLMPFI.js → chunk-YLST4S4P.js} +103 -13
- package/dist/chunk-YLST4S4P.js.map +1 -0
- package/dist/{chunk-EBXJ45VZ.js → chunk-Z2WI3E4N.js} +2 -2
- package/dist/{chunk-EBXJ45VZ.js.map → chunk-Z2WI3E4N.js.map} +1 -1
- package/dist/{chunk-7LOD4IGO.js → chunk-ZTGTFO52.js} +4 -4
- package/dist/chunks-T67OQGPJ.js +10 -0
- package/dist/cli.js +39 -28
- package/dist/cli.js.map +1 -1
- package/dist/{formula-DAMFHLQO.js → formula-G4YA7SNQ.js} +3 -3
- package/dist/{formula-HJNQGPRC.cjs → formula-J3UUIPCX.cjs} +9 -9
- package/dist/{formula-HJNQGPRC.cjs.map → formula-J3UUIPCX.cjs.map} +1 -1
- package/dist/{formula-YCAO5IVW.js → formula-QSZRYZ44.js} +4 -4
- package/dist/{image-ocr-AZ25IOC7.cjs → image-ocr-467KLV3F.cjs} +15 -15
- package/dist/{image-ocr-AZ25IOC7.cjs.map → image-ocr-467KLV3F.cjs.map} +1 -1
- package/dist/{image-ocr-VH54SDZ7.js → image-ocr-I52GBXRE.js} +6 -6
- package/dist/{image-ocr-PAF76DAW.js → image-ocr-ZP3F4MUY.js} +9 -9
- 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-FEUM7XXS.js} +5 -5
- package/dist/{models-UVLAKK3M.js → models-6QCNX5YR.js} +5 -5
- package/dist/{parser-I4D3TRGU.js → parser-6EIBURDE.js} +179 -13
- package/dist/parser-6EIBURDE.js.map +1 -0
- package/dist/{parser-HWAOPQYK.cjs → parser-BIJBX2D5.cjs} +393 -227
- package/dist/parser-BIJBX2D5.cjs.map +1 -0
- package/dist/{parser-Z6PHB54O.js → parser-YX4LGKIK.js} +176 -10
- package/dist/parser-YX4LGKIK.js.map +1 -0
- package/dist/pdf-ocr-DXQIMO77.cjs +17 -0
- package/dist/{pdf-ocr-HR6CXGTX.cjs.map → pdf-ocr-DXQIMO77.cjs.map} +1 -1
- package/dist/pdf-ocr-MESGGING.js +20 -0
- package/dist/pdf-ocr-YSRBRIPR.js +16 -0
- package/dist/{profile-io-WHCWCOPW.js → profile-io-ATHFEUAP.js} +3 -3
- package/dist/{rasterize-5DZ3DHGH.js → rasterize-SG3CLXMQ.js} +3 -3
- package/dist/{redact-doc-RNJVMFGQ.js → redact-doc-K3S4HFHU.js} +11 -11
- package/dist/{render-NZ6RA6SW.js → render-6CQJM7VE.js} +7 -7
- package/dist/seal-SMO4544N.js +10 -0
- package/dist/{setup-U3EQNK4Z.js → setup-CZ5KHGPI.js} +3 -3
- package/dist/visual-UWYGQLOU.js +20 -0
- package/dist/{watch-GB2M7XU6.js → watch-RQRIGLFF.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/parser-I4D3TRGU.js.map +0 -1
- package/dist/parser-Z6PHB54O.js.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 → -LYUUVVQF.js.map} +0 -0
- /package/dist/{chunk-ISC2TH24.js.map → chunk-4WTJS6ES.js.map} +0 -0
- /package/dist/{chunk-PHMWSWHJ.js.map → chunk-7XRI4FL4.js.map} +0 -0
- /package/dist/{chunk-32ZUIHSY.js.map → chunk-ADBES5QJ.js.map} +0 -0
- /package/dist/{chunk-JWTZ3OVZ.js.map → chunk-BDTWXJNM.js.map} +0 -0
- /package/dist/{chunk-INESPVEV.js.map → chunk-CL3CJ7X5.js.map} +0 -0
- /package/dist/{chunk-VDEENOPW.js.map → chunk-DQHDI567.js.map} +0 -0
- /package/dist/{chunk-ZNY5BRV6.js.map → chunk-FEGRQA3Q.js.map} +0 -0
- /package/dist/{chunk-IRN5SDY2.js.map → chunk-JA5B4NPF.js.map} +0 -0
- /package/dist/{chunk-EZSWBHHI.js.map → chunk-KYFP5LDC.js.map} +0 -0
- /package/dist/{chunk-6AYTYTFY.js.map → chunk-MSUGYK6A.js.map} +0 -0
- /package/dist/{chunk-DHEUQXXR.js.map → chunk-UAAYIEIK.js.map} +0 -0
- /package/dist/{chunk-V7LKQNC4.js.map → chunk-X6ME7YYS.js.map} +0 -0
- /package/dist/{chunk-LKA7Z2NH.js.map → chunk-XFZMRCGJ.js.map} +0 -0
- /package/dist/{chunk-7LOD4IGO.js.map → chunk-ZTGTFO52.js.map} +0 -0
- /package/dist/{chunks-JZW2TXIZ.js.map → chunks-T67OQGPJ.js.map} +0 -0
- /package/dist/{formula-DAMFHLQO.js.map → formula-G4YA7SNQ.js.map} +0 -0
- /package/dist/{formula-YCAO5IVW.js.map → formula-QSZRYZ44.js.map} +0 -0
- /package/dist/{image-ocr-VH54SDZ7.js.map → image-ocr-I52GBXRE.js.map} +0 -0
- /package/dist/{image-ocr-PAF76DAW.js.map → image-ocr-ZP3F4MUY.js.map} +0 -0
- /package/dist/{model-bundle-53CHDYCG.js.map → model-bundle-FEUM7XXS.js.map} +0 -0
- /package/dist/{models-UVLAKK3M.js.map → models-6QCNX5YR.js.map} +0 -0
- /package/dist/{pdf-ocr-F4ICXO7W.js.map → pdf-ocr-MESGGING.js.map} +0 -0
- /package/dist/{pdf-ocr-JI3K7JIN.js.map → pdf-ocr-YSRBRIPR.js.map} +0 -0
- /package/dist/{profile-io-WHCWCOPW.js.map → profile-io-ATHFEUAP.js.map} +0 -0
- /package/dist/{rasterize-5DZ3DHGH.js.map → rasterize-SG3CLXMQ.js.map} +0 -0
- /package/dist/{redact-doc-RNJVMFGQ.js.map → redact-doc-K3S4HFHU.js.map} +0 -0
- /package/dist/{render-NZ6RA6SW.js.map → render-6CQJM7VE.js.map} +0 -0
- /package/dist/{seal-WHJ6O5HT.js.map → seal-SMO4544N.js.map} +0 -0
- /package/dist/{setup-U3EQNK4Z.js.map → setup-CZ5KHGPI.js.map} +0 -0
- /package/dist/{visual-JDAS4R43.js.map → visual-UWYGQLOU.js.map} +0 -0
- /package/dist/{watch-GB2M7XU6.js.map → watch-RQRIGLFF.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 _chunkRHMIEEAZcjs = require('./chunk-RHMIEEAZ.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 = _chunkRHMIEEAZcjs.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 = _chunkRHMIEEAZcjs.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 _chunkRHMIEEAZcjs.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="${_chunkRHMIEEAZcjs.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);
|
|
976
|
+
}
|
|
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;
|
|
945
1015
|
}
|
|
946
|
-
function tableToMarkdown(table) {
|
|
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
|
}
|
|
@@ -1003,6 +1086,7 @@ function tableToMarkdown(table) {
|
|
|
1003
1086
|
|
|
1004
1087
|
// src/table/layout-frames.ts
|
|
1005
1088
|
var CELL_EDGES = /* @__PURE__ */ new WeakMap();
|
|
1089
|
+
var CELL_PAGES = /* @__PURE__ */ new WeakMap();
|
|
1006
1090
|
var CONTENT_CELLS = /* @__PURE__ */ new WeakSet();
|
|
1007
1091
|
var FRACTION_MAX_CHARS = 40;
|
|
1008
1092
|
function anchorsOf(t) {
|
|
@@ -1010,7 +1094,7 @@ function anchorsOf(t) {
|
|
|
1010
1094
|
const covered = /* @__PURE__ */ new Set();
|
|
1011
1095
|
for (let r = 0; r < t.rows; r++) for (let c = 0; c < t.cols; c++) {
|
|
1012
1096
|
if (covered.has(r * t.cols + c)) continue;
|
|
1013
|
-
const cell = _optionalChain([t, 'access',
|
|
1097
|
+
const cell = _optionalChain([t, 'access', _59 => _59.cells, 'access', _60 => _60[r], 'optionalAccess', _61 => _61[c]]);
|
|
1014
1098
|
if (!cell) continue;
|
|
1015
1099
|
const rs = Math.max(1, Math.min(cell.rowSpan, t.rows - r)), cs = Math.max(1, Math.min(cell.colSpan, t.cols - c));
|
|
1016
1100
|
for (let dr = 0; dr < rs; dr++) for (let dc = 0; dc < cs; dc++) covered.add((r + dr) * t.cols + c + dc);
|
|
@@ -1039,7 +1123,7 @@ function toTex(s) {
|
|
|
1039
1123
|
}
|
|
1040
1124
|
function fractionPart(cell) {
|
|
1041
1125
|
const t = cell.text.trim();
|
|
1042
|
-
return !!t && !t.includes("\n") && !_optionalChain([cell, 'access',
|
|
1126
|
+
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
1127
|
}
|
|
1044
1128
|
function mergeFractions(t, anchors, H, V) {
|
|
1045
1129
|
const at = /* @__PURE__ */ new Map();
|
|
@@ -1074,7 +1158,7 @@ function bandTable(t, anchors, V, H, r0, r1, keepEmptyCols) {
|
|
|
1074
1158
|
let list = anchors.filter((a) => a.r >= r0 && a.r <= r1).map((a) => ({ ...a, rs: Math.min(a.rs, r1 - a.r + 1) }));
|
|
1075
1159
|
const blank = (a) => {
|
|
1076
1160
|
if (CONTENT_CELLS.has(a.cell)) return false;
|
|
1077
|
-
if (!_optionalChain([a, 'access',
|
|
1161
|
+
if (!_optionalChain([a, 'access', _64 => _64.cell, 'access', _65 => _65.blocks, 'optionalAccess', _66 => _66.length])) return !a.cell.text.trim();
|
|
1078
1162
|
return a.cell.blocks.every((b) => (b.type === "paragraph" || b.type === "heading") && !visibleText(b).trim() && !b.footnoteText);
|
|
1079
1163
|
};
|
|
1080
1164
|
let lo = Infinity, hi = -Infinity;
|
|
@@ -1138,7 +1222,7 @@ function textRow(row, out, pageNumber, keepEmptyCols) {
|
|
|
1138
1222
|
parts.length = 0;
|
|
1139
1223
|
};
|
|
1140
1224
|
for (const a of row) {
|
|
1141
|
-
if (_optionalChain([a, 'access',
|
|
1225
|
+
if (_optionalChain([a, 'access', _67 => _67.cell, 'access', _68 => _68.blocks, 'optionalAccess', _69 => _69.length])) {
|
|
1142
1226
|
flush();
|
|
1143
1227
|
out.push(...unframeLayoutTables(a.cell.blocks, keepEmptyCols));
|
|
1144
1228
|
continue;
|
|
@@ -1172,18 +1256,22 @@ function unframeTable(t, pageNumber, keepEmptyCols) {
|
|
|
1172
1256
|
}, pageNumber }];
|
|
1173
1257
|
}
|
|
1174
1258
|
const out = [];
|
|
1175
|
-
if (_optionalChain([t, 'access',
|
|
1259
|
+
if (_optionalChain([t, 'access', _70 => _70.captionBlocks, 'optionalAccess', _71 => _71.length])) out.push(...t.captionBlocks);
|
|
1176
1260
|
else if (t.caption) out.push({ type: "paragraph", text: t.caption, pageNumber });
|
|
1261
|
+
const rowPage = (r) => {
|
|
1262
|
+
const marks = anchors.filter((a) => a.r === r).map((a) => CELL_PAGES.get(a.cell)).filter((p) => p !== void 0);
|
|
1263
|
+
return marks.length ? Math.max(...marks) : pageNumber;
|
|
1264
|
+
};
|
|
1177
1265
|
for (let r = 0; r < t.rows; ) {
|
|
1178
1266
|
if (ruled[r]) {
|
|
1179
1267
|
let r1 = r;
|
|
1180
1268
|
while (r1 + 1 < t.rows && ruled[r1 + 1]) r1++;
|
|
1181
1269
|
const sub = bandTable(t, anchors, V, H, r, r1, keepEmptyCols);
|
|
1182
|
-
if (sub) out.push({ type: "table", table: sub, pageNumber });
|
|
1270
|
+
if (sub) out.push({ type: "table", table: sub, pageNumber: rowPage(r) });
|
|
1183
1271
|
r = r1 + 1;
|
|
1184
1272
|
continue;
|
|
1185
1273
|
}
|
|
1186
|
-
textRow(anchors.filter((a) => a.r === r).sort((x, y) => x.c - y.c), out,
|
|
1274
|
+
textRow(anchors.filter((a) => a.r === r).sort((x, y) => x.c - y.c), out, rowPage(r), keepEmptyCols);
|
|
1187
1275
|
r++;
|
|
1188
1276
|
}
|
|
1189
1277
|
return out;
|
|
@@ -1195,12 +1283,12 @@ function unframeLayoutTables(blocks, keepEmptyCols = false) {
|
|
|
1195
1283
|
out.push(b);
|
|
1196
1284
|
continue;
|
|
1197
1285
|
}
|
|
1198
|
-
if (_optionalChain([b, 'access',
|
|
1286
|
+
if (_optionalChain([b, 'access', _72 => _72.table, 'access', _73 => _73.captionBlocks, 'optionalAccess', _74 => _74.length])) b.table.captionBlocks = unframeLayoutTables(b.table.captionBlocks, keepEmptyCols);
|
|
1199
1287
|
const flat = unframeTable(b.table, b.pageNumber, keepEmptyCols);
|
|
1200
1288
|
const kept = _nullishCoalesce(flat, () => ( [b]));
|
|
1201
1289
|
for (const k of kept) {
|
|
1202
1290
|
if (k.type === "table" && k.table) {
|
|
1203
|
-
for (const row of k.table.cells) for (const cell of row) if (_optionalChain([cell, 'access',
|
|
1291
|
+
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
1292
|
}
|
|
1205
1293
|
out.push(k);
|
|
1206
1294
|
}
|
|
@@ -1241,5 +1329,7 @@ var HEADING_RATIO_H3 = 1.15;
|
|
|
1241
1329
|
|
|
1242
1330
|
|
|
1243
1331
|
|
|
1244
|
-
|
|
1245
|
-
|
|
1332
|
+
|
|
1333
|
+
|
|
1334
|
+
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.CELL_PAGES = CELL_PAGES; 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;
|
|
1335
|
+
//# sourceMappingURL=chunk-W5NXOMCD.cjs.map
|