kordoc 2.2.2 → 2.2.3
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-R34CFFNV.js → chunk-AIG7SDWU.js} +40 -2
- package/dist/chunk-AIG7SDWU.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/index.cjs +39 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +1 -1
- package/dist/{watch-VNJDVUVQ.js → watch-H672QAW2.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-R34CFFNV.js.map +0 -1
- /package/dist/{watch-VNJDVUVQ.js.map → watch-H672QAW2.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -139,7 +139,7 @@ import { inflateRawSync } from "zlib";
|
|
|
139
139
|
import { DOMParser } from "@xmldom/xmldom";
|
|
140
140
|
|
|
141
141
|
// src/utils.ts
|
|
142
|
-
var VERSION = true ? "2.2.
|
|
142
|
+
var VERSION = true ? "2.2.3" : "0.0.0-dev";
|
|
143
143
|
function toArrayBuffer(buf) {
|
|
144
144
|
if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
|
|
145
145
|
return buf.buffer;
|
|
@@ -457,9 +457,47 @@ function blocksToMarkdown(blocks) {
|
|
|
457
457
|
}
|
|
458
458
|
return lines.join("\n").trim();
|
|
459
459
|
}
|
|
460
|
+
function hasMergedCells(table) {
|
|
461
|
+
for (const row of table.cells) {
|
|
462
|
+
for (const cell of row) {
|
|
463
|
+
if (cell.colSpan > 1 || cell.rowSpan > 1) return true;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
function tableToHtml(table) {
|
|
469
|
+
const { cells, rows: numRows, cols: numCols } = table;
|
|
470
|
+
const skip = /* @__PURE__ */ new Set();
|
|
471
|
+
const lines = ["<table>"];
|
|
472
|
+
for (let r = 0; r < numRows; r++) {
|
|
473
|
+
const tag = r === 0 ? "th" : "td";
|
|
474
|
+
const rowHtml = [];
|
|
475
|
+
for (let c = 0; c < numCols; c++) {
|
|
476
|
+
if (skip.has(`${r},${c}`)) continue;
|
|
477
|
+
const cell = cells[r]?.[c];
|
|
478
|
+
if (!cell) continue;
|
|
479
|
+
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
480
|
+
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
481
|
+
if (dr === 0 && dc === 0) continue;
|
|
482
|
+
if (r + dr < numRows && c + dc < numCols) skip.add(`${r + dr},${c + dc}`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
const text = sanitizeText(cell.text).replace(/\n/g, "<br>");
|
|
486
|
+
const attrs = [];
|
|
487
|
+
if (cell.colSpan > 1) attrs.push(`colspan="${cell.colSpan}"`);
|
|
488
|
+
if (cell.rowSpan > 1) attrs.push(`rowspan="${cell.rowSpan}"`);
|
|
489
|
+
const attrStr = attrs.length ? " " + attrs.join(" ") : "";
|
|
490
|
+
rowHtml.push(`<${tag}${attrStr}>${text}</${tag}>`);
|
|
491
|
+
}
|
|
492
|
+
if (rowHtml.length) lines.push(`<tr>${rowHtml.join("")}</tr>`);
|
|
493
|
+
}
|
|
494
|
+
lines.push("</table>");
|
|
495
|
+
return lines.join("\n");
|
|
496
|
+
}
|
|
460
497
|
function tableToMarkdown(table) {
|
|
461
498
|
if (table.rows === 0 || table.cols === 0) return "";
|
|
462
499
|
const { cells, rows: numRows, cols: numCols } = table;
|
|
500
|
+
if (hasMergedCells(table)) return tableToHtml(table);
|
|
463
501
|
if (numRows === 1 && numCols === 1) {
|
|
464
502
|
const content = sanitizeText(cells[0][0].text);
|
|
465
503
|
if (!content) return "";
|