kordoc 1.8.0 → 1.9.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/dist/{chunk-UUKFY5P5.js → chunk-AHW56LNX.js} +2 -2
- package/dist/{chunk-QQ6PZADA.js → chunk-MDRW3HYC.js} +51 -10
- package/dist/chunk-MDRW3HYC.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +50 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +2 -2
- package/dist/{utils-OTCR2KMY.js → utils-VU6Z7HNR.js} +2 -2
- package/dist/{watch-JFDOENIO.js → watch-5IOZWFDD.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-QQ6PZADA.js.map +0 -1
- /package/dist/{chunk-UUKFY5P5.js.map → chunk-AHW56LNX.js.map} +0 -0
- /package/dist/{utils-OTCR2KMY.js.map → utils-VU6Z7HNR.js.map} +0 -0
- /package/dist/{watch-JFDOENIO.js.map → watch-5IOZWFDD.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/utils.ts
|
|
4
|
-
var VERSION = true ? "1.
|
|
4
|
+
var VERSION = true ? "1.9.0" : "0.0.0-dev";
|
|
5
5
|
function toArrayBuffer(buf) {
|
|
6
6
|
if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
|
|
7
7
|
return buf.buffer;
|
|
@@ -90,4 +90,4 @@ export {
|
|
|
90
90
|
sanitizeHref,
|
|
91
91
|
classifyError
|
|
92
92
|
};
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-AHW56LNX.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
precheckZipSize,
|
|
7
7
|
sanitizeHref,
|
|
8
8
|
toArrayBuffer
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AHW56LNX.js";
|
|
10
10
|
import {
|
|
11
11
|
parsePageRange
|
|
12
12
|
} from "./chunk-MOL7MDBG.js";
|
|
@@ -61,23 +61,24 @@ var MAX_ROWS = 1e4;
|
|
|
61
61
|
function buildTable(rows) {
|
|
62
62
|
if (rows.length > MAX_ROWS) rows = rows.slice(0, MAX_ROWS);
|
|
63
63
|
const numRows = rows.length;
|
|
64
|
-
const
|
|
64
|
+
const hasAddr = rows.some((row) => row.some((c) => c.colAddr !== void 0 && c.rowAddr !== void 0));
|
|
65
|
+
if (hasAddr) return buildTableDirect(rows, numRows);
|
|
65
66
|
let maxCols = 0;
|
|
67
|
+
const tempOccupied = Array.from({ length: numRows }, () => []);
|
|
66
68
|
for (let rowIdx = 0; rowIdx < numRows; rowIdx++) {
|
|
67
69
|
let colIdx = 0;
|
|
68
70
|
for (const cell of rows[rowIdx]) {
|
|
69
|
-
while (colIdx < MAX_COLS && tempOccupied
|
|
71
|
+
while (colIdx < MAX_COLS && tempOccupied[rowIdx][colIdx]) colIdx++;
|
|
70
72
|
if (colIdx >= MAX_COLS) break;
|
|
71
73
|
for (let r = rowIdx; r < Math.min(rowIdx + cell.rowSpan, numRows); r++) {
|
|
72
74
|
for (let c = colIdx; c < Math.min(colIdx + cell.colSpan, MAX_COLS); c++) {
|
|
73
|
-
tempOccupied
|
|
75
|
+
tempOccupied[r][c] = true;
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
colIdx += cell.colSpan;
|
|
77
79
|
if (colIdx > maxCols) maxCols = colIdx;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
|
-
tempOccupied.clear();
|
|
81
82
|
if (maxCols === 0) return { rows: 0, cols: 0, cells: [], hasHeader: false };
|
|
82
83
|
const grid = Array.from(
|
|
83
84
|
{ length: numRows },
|
|
@@ -105,6 +106,40 @@ function buildTable(rows) {
|
|
|
105
106
|
cellIdx++;
|
|
106
107
|
}
|
|
107
108
|
}
|
|
109
|
+
return trimAndReturn(grid, numRows, maxCols);
|
|
110
|
+
}
|
|
111
|
+
function buildTableDirect(rows, numRows) {
|
|
112
|
+
let maxCols = 0;
|
|
113
|
+
for (const row of rows) {
|
|
114
|
+
for (const cell of row) {
|
|
115
|
+
const end = (cell.colAddr ?? 0) + cell.colSpan;
|
|
116
|
+
if (end > maxCols) maxCols = end;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (maxCols === 0) return { rows: 0, cols: 0, cells: [], hasHeader: false };
|
|
120
|
+
const grid = Array.from(
|
|
121
|
+
{ length: numRows },
|
|
122
|
+
() => Array.from({ length: maxCols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }))
|
|
123
|
+
);
|
|
124
|
+
for (const row of rows) {
|
|
125
|
+
for (const cell of row) {
|
|
126
|
+
const r = cell.rowAddr ?? 0;
|
|
127
|
+
const c = cell.colAddr ?? 0;
|
|
128
|
+
if (r >= numRows || c >= maxCols) continue;
|
|
129
|
+
grid[r][c] = { text: cell.text.trim(), colSpan: cell.colSpan, rowSpan: cell.rowSpan };
|
|
130
|
+
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
131
|
+
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
132
|
+
if (dr === 0 && dc === 0) continue;
|
|
133
|
+
if (r + dr < numRows && c + dc < maxCols) {
|
|
134
|
+
grid[r + dr][c + dc] = { text: "", colSpan: 1, rowSpan: 1 };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return trimAndReturn(grid, numRows, maxCols);
|
|
141
|
+
}
|
|
142
|
+
function trimAndReturn(grid, numRows, maxCols) {
|
|
108
143
|
let effectiveCols = maxCols;
|
|
109
144
|
while (effectiveCols > 0) {
|
|
110
145
|
const colEmpty = grid.every((row) => !row[effectiveCols - 1]?.text?.trim());
|
|
@@ -220,12 +255,10 @@ function tableToMarkdown(table) {
|
|
|
220
255
|
const display = Array.from({ length: numRows }, () => Array(numCols).fill(""));
|
|
221
256
|
const skip = /* @__PURE__ */ new Set();
|
|
222
257
|
for (let r = 0; r < numRows; r++) {
|
|
223
|
-
let cellIdx = 0;
|
|
224
258
|
for (let c = 0; c < numCols; c++) {
|
|
225
259
|
if (skip.has(`${r},${c}`)) continue;
|
|
226
|
-
const cell = cells[r]?.[
|
|
227
|
-
if (!cell)
|
|
228
|
-
cellIdx++;
|
|
260
|
+
const cell = cells[r]?.[c];
|
|
261
|
+
if (!cell) continue;
|
|
229
262
|
display[r][c] = sanitizeText(cell.text).replace(/\n/g, "<br>");
|
|
230
263
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
231
264
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -762,6 +795,14 @@ function walkSection(node, blocks, tableCtx, tableStack, styleMap, warnings, sec
|
|
|
762
795
|
}
|
|
763
796
|
}
|
|
764
797
|
break;
|
|
798
|
+
case "cellAddr":
|
|
799
|
+
if (tableCtx?.cell) {
|
|
800
|
+
const ca = parseInt(el.getAttribute("colAddr") || "", 10);
|
|
801
|
+
const ra = parseInt(el.getAttribute("rowAddr") || "", 10);
|
|
802
|
+
if (!isNaN(ca)) tableCtx.cell.colAddr = ca;
|
|
803
|
+
if (!isNaN(ra)) tableCtx.cell.rowAddr = ra;
|
|
804
|
+
}
|
|
805
|
+
break;
|
|
765
806
|
case "cellSpan":
|
|
766
807
|
if (tableCtx?.cell) {
|
|
767
808
|
const cs = parseInt(el.getAttribute("colSpan") || "1", 10);
|
|
@@ -4261,4 +4302,4 @@ export {
|
|
|
4261
4302
|
extractFormFields,
|
|
4262
4303
|
parse
|
|
4263
4304
|
};
|
|
4264
|
-
//# sourceMappingURL=chunk-
|
|
4305
|
+
//# sourceMappingURL=chunk-MDRW3HYC.js.map
|