kordoc 2.2.0 → 2.2.2

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.
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-MOL7MDBG.js";
9
9
 
10
10
  // src/utils.ts
11
- var VERSION = true ? "2.2.0" : "0.0.0-dev";
11
+ var VERSION = true ? "2.2.2" : "0.0.0-dev";
12
12
  function toArrayBuffer(buf) {
13
13
  if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
14
14
  return buf.buffer;
@@ -201,9 +201,12 @@ function trimAndReturn(grid, numRows, maxCols) {
201
201
  }
202
202
  function convertTableToText(rows) {
203
203
  return rows.map(
204
- (row) => row.map((c) => c.text.trim().replace(/\n/g, " ")).filter(Boolean).join(" | ")
204
+ (row) => row.map((c) => c.text.trim().replace(/\n/g, " ").replace(/\|/g, "\\|")).filter(Boolean).join(" / ")
205
205
  ).filter(Boolean).join("\n");
206
206
  }
207
+ function escapeGfm(text) {
208
+ return text.replace(/~/g, "\\~");
209
+ }
207
210
  var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
208
211
  function sanitizeText(text) {
209
212
  let result = text.replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
@@ -313,7 +316,7 @@ function blocksToMarkdown(blocks) {
313
316
  if (block.footnoteText) {
314
317
  text += ` (\uC8FC: ${block.footnoteText})`;
315
318
  }
316
- lines.push(text);
319
+ lines.push(escapeGfm(text), "");
317
320
  } else if (block.type === "table" && block.table) {
318
321
  if (lines.length > 0 && lines[lines.length - 1] !== "") {
319
322
  lines.push("");
@@ -336,13 +339,13 @@ function tableToMarkdown(table) {
336
339
  return content.split(/\n/).map((line) => {
337
340
  const trimmed = line.trim();
338
341
  if (!trimmed) return "";
339
- if (/^\d+\.\s/.test(trimmed)) return `**${trimmed}**`;
340
- if (/^[가-힣]\.\s/.test(trimmed)) return ` ${trimmed}`;
341
- return trimmed;
342
+ if (/^\d+\.\s/.test(trimmed)) return `**${escapeGfm(trimmed)}**`;
343
+ if (/^[가-힣]\.\s/.test(trimmed)) return ` ${escapeGfm(trimmed)}`;
344
+ return escapeGfm(trimmed);
342
345
  }).filter(Boolean).join("\n");
343
346
  }
344
347
  if (numCols === 1 && numRows >= 2) {
345
- return cells.map((row) => sanitizeText(row[0].text).replace(/\n/g, " ")).filter(Boolean).join("\n");
348
+ return cells.map((row) => escapeGfm(sanitizeText(row[0].text)).replace(/\n/g, " ")).filter(Boolean).join("\n");
346
349
  }
347
350
  const display = Array.from({ length: numRows }, () => Array(numCols).fill(""));
348
351
  const skip = /* @__PURE__ */ new Set();
@@ -351,7 +354,7 @@ function tableToMarkdown(table) {
351
354
  if (skip.has(`${r},${c}`)) continue;
352
355
  const cell = cells[r]?.[c];
353
356
  if (!cell) continue;
354
- display[r][c] = sanitizeText(cell.text).replace(/\n/g, "<br>");
357
+ display[r][c] = escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>");
355
358
  for (let dr = 0; dr < cell.rowSpan; dr++) {
356
359
  for (let dc = 0; dc < cell.colSpan; dc++) {
357
360
  if (dr === 0 && dc === 0) continue;
@@ -6257,4 +6260,4 @@ export {
6257
6260
  extractFormFields,
6258
6261
  parse
6259
6262
  };
6260
- //# sourceMappingURL=chunk-LYFG7AUT.js.map
6263
+ //# sourceMappingURL=chunk-R34CFFNV.js.map