kordoc 4.0.4 → 4.0.6

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.
Files changed (86) hide show
  1. package/README.md +806 -800
  2. package/dist/{-Q4ZCVQFI.js → -NDU7YGSS.js} +8 -8
  3. package/dist/{chunk-DKMKJMR6.js → chunk-4C7SBZNW.js} +2 -2
  4. package/dist/chunk-4C7SBZNW.js.map +1 -0
  5. package/dist/{chunk-MEPHGCPQ.js → chunk-5CJGKKMZ.js} +1 -1
  6. package/dist/chunk-5CJGKKMZ.js.map +1 -0
  7. package/dist/{chunk-S3KGEEBQ.js → chunk-5SOZXPQY.js} +3 -3
  8. package/dist/chunk-5SOZXPQY.js.map +1 -0
  9. package/dist/{chunk-TXNRIVWA.js → chunk-63ASYC4N.js} +3 -3
  10. package/dist/chunk-63ASYC4N.js.map +1 -0
  11. package/dist/{chunk-5RPYBC2Q.js → chunk-6GBLFQMA.js} +1 -1
  12. package/dist/chunk-6GBLFQMA.js.map +1 -0
  13. package/dist/chunk-DCZVOIEO.cjs.map +1 -1
  14. package/dist/{chunk-NIW7CZYX.cjs → chunk-DQJTNXVS.cjs} +5 -4
  15. package/dist/chunk-DQJTNXVS.cjs.map +1 -0
  16. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  17. package/dist/{chunk-MLNHZN32.js → chunk-HC2SEH6I.js} +90 -17
  18. package/dist/chunk-HC2SEH6I.js.map +1 -0
  19. package/dist/{chunk-KSVLQ5BC.js → chunk-HOGJ5ALY.js} +5 -4
  20. package/dist/chunk-HOGJ5ALY.js.map +1 -0
  21. package/dist/{chunk-2RIOXYGA.js → chunk-KA4FEBS2.js} +2 -2
  22. package/dist/chunk-KA4FEBS2.js.map +1 -0
  23. package/dist/{chunk-KA5AN73R.js → chunk-L3I4TIRP.js} +2 -2
  24. package/dist/chunk-L3I4TIRP.js.map +1 -0
  25. package/dist/chunk-MOL7MDBG.js +0 -0
  26. package/dist/{chunk-ZJXR4PWY.js → chunk-UVSOSFER.js} +5 -4
  27. package/dist/chunk-UVSOSFER.js.map +1 -0
  28. package/dist/cli.js +15 -15
  29. package/dist/cli.js.map +1 -1
  30. package/dist/{detect-RI2MQ33K.js → detect-PJZMUL2Z.js} +2 -2
  31. package/dist/formula-5NKVS2LR.cjs.map +1 -1
  32. package/dist/formula-JCNF43NE.js +0 -0
  33. package/dist/index.cjs +437 -364
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +7 -1
  36. package/dist/index.d.ts +7 -1
  37. package/dist/index.js +84 -11
  38. package/dist/index.js.map +1 -1
  39. package/dist/mcp.js +13 -13
  40. package/dist/mcp.js.map +1 -1
  41. package/dist/page-range-737B4EZW.js +0 -0
  42. package/dist/page-range-P7SDW6LR.cjs.map +1 -1
  43. package/dist/{parser-46JGSTPR.js → parser-C636QIOB.js} +72 -4
  44. package/dist/parser-C636QIOB.js.map +1 -0
  45. package/dist/{parser-TLCC67W6.js → parser-DMKHIV4E.js} +71 -3
  46. package/dist/parser-DMKHIV4E.js.map +1 -0
  47. package/dist/{parser-2ZUTCU2G.cjs → parser-VEY4B5CJ.cjs} +83 -15
  48. package/dist/parser-VEY4B5CJ.cjs.map +1 -0
  49. package/dist/{profile-io-MRVIJ5T4.js → profile-io-JYGCC6XQ.js} +3 -3
  50. package/dist/{provider-G4C2V2PD.cjs → provider-5K7O3Z2O.cjs} +1 -1
  51. package/dist/provider-5K7O3Z2O.cjs.map +1 -0
  52. package/dist/{provider-AKROB7WQ.js → provider-7H4CPZYS.js} +1 -1
  53. package/dist/provider-7H4CPZYS.js.map +1 -0
  54. package/dist/{provider-4ZJKV3DC.js → provider-H4WWSPOV.js} +1 -1
  55. package/dist/provider-H4WWSPOV.js.map +1 -0
  56. package/dist/render-ISOEOMTM.js +10 -0
  57. package/dist/seal-676ZIAZZ.js +10 -0
  58. package/dist/setup-57FB3LSP.js +0 -0
  59. package/dist/{watch-NZNVJ4YD.js → watch-ZQUFJBFR.js} +8 -8
  60. package/dist/watch-ZQUFJBFR.js.map +1 -0
  61. package/package.json +97 -97
  62. package/dist/chunk-2RIOXYGA.js.map +0 -1
  63. package/dist/chunk-5RPYBC2Q.js.map +0 -1
  64. package/dist/chunk-DKMKJMR6.js.map +0 -1
  65. package/dist/chunk-KA5AN73R.js.map +0 -1
  66. package/dist/chunk-KSVLQ5BC.js.map +0 -1
  67. package/dist/chunk-MEPHGCPQ.js.map +0 -1
  68. package/dist/chunk-MLNHZN32.js.map +0 -1
  69. package/dist/chunk-NIW7CZYX.cjs.map +0 -1
  70. package/dist/chunk-S3KGEEBQ.js.map +0 -1
  71. package/dist/chunk-TXNRIVWA.js.map +0 -1
  72. package/dist/chunk-ZJXR4PWY.js.map +0 -1
  73. package/dist/parser-2ZUTCU2G.cjs.map +0 -1
  74. package/dist/parser-46JGSTPR.js.map +0 -1
  75. package/dist/parser-TLCC67W6.js.map +0 -1
  76. package/dist/provider-4ZJKV3DC.js.map +0 -1
  77. package/dist/provider-AKROB7WQ.js.map +0 -1
  78. package/dist/provider-G4C2V2PD.cjs.map +0 -1
  79. package/dist/render-TTOG6CHW.js +0 -10
  80. package/dist/seal-NMLZ3M3K.js +0 -10
  81. package/dist/watch-NZNVJ4YD.js.map +0 -1
  82. /package/dist/{-Q4ZCVQFI.js.map → -NDU7YGSS.js.map} +0 -0
  83. /package/dist/{detect-RI2MQ33K.js.map → detect-PJZMUL2Z.js.map} +0 -0
  84. /package/dist/{profile-io-MRVIJ5T4.js.map → profile-io-JYGCC6XQ.js.map} +0 -0
  85. /package/dist/{render-TTOG6CHW.js.map → render-ISOEOMTM.js.map} +0 -0
  86. /package/dist/{seal-NMLZ3M3K.js.map → seal-676ZIAZZ.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -39,7 +39,7 @@ interface IRBlock {
39
39
  footnoteText?: string;
40
40
  /** 이미지 데이터 (type="image"일 때) */
41
41
  imageData?: ImageData;
42
- /** 인라인 강조 run-span (선택 — 현재 kordoc 생성 hwpx 왕복 채널만 채움).
42
+ /** 인라인 강조 run-span (선택 — kordoc 생성 hwpx 왕복 채널 + 외래 실속성 볼드/이탤릭).
43
43
  * 존재하면 마크다운 변환이 **·*·` 마커를 재방출한다 */
44
44
  spans?: IRSpan[];
45
45
  /** 인용문 문단 (선택 — kordoc 생성 hwpx 왕복 채널) — 마크다운 변환이 "> " 접두 재방출 */
@@ -50,6 +50,12 @@ interface IRBlock {
50
50
  * depth 재유도·양식 분석 등 소비자 몫 (v4.0.4)
51
51
  */
52
52
  indent?: number;
53
+ /**
54
+ * gongmun 리스트 단계(1~7, 선택) — indent를 levelIndent 단위로 역산한 소비 결과
55
+ * (v4.0.5). md 리스트 문법과 충돌하는 부호('- '·'1) ') 문단에만 채워지며,
56
+ * 마크다운 변환이 2칸/단계 선행 공백을 방출해 재생성 시 depth가 복원된다
57
+ */
58
+ listDepth?: number;
53
59
  }
54
60
  /** 추출된 이미지 바이너리 데이터 */
55
61
  interface ImageData {
package/dist/index.d.ts CHANGED
@@ -39,7 +39,7 @@ interface IRBlock {
39
39
  footnoteText?: string;
40
40
  /** 이미지 데이터 (type="image"일 때) */
41
41
  imageData?: ImageData;
42
- /** 인라인 강조 run-span (선택 — 현재 kordoc 생성 hwpx 왕복 채널만 채움).
42
+ /** 인라인 강조 run-span (선택 — kordoc 생성 hwpx 왕복 채널 + 외래 실속성 볼드/이탤릭).
43
43
  * 존재하면 마크다운 변환이 **·*·` 마커를 재방출한다 */
44
44
  spans?: IRSpan[];
45
45
  /** 인용문 문단 (선택 — kordoc 생성 hwpx 왕복 채널) — 마크다운 변환이 "> " 접두 재방출 */
@@ -50,6 +50,12 @@ interface IRBlock {
50
50
  * depth 재유도·양식 분석 등 소비자 몫 (v4.0.4)
51
51
  */
52
52
  indent?: number;
53
+ /**
54
+ * gongmun 리스트 단계(1~7, 선택) — indent를 levelIndent 단위로 역산한 소비 결과
55
+ * (v4.0.5). md 리스트 문법과 충돌하는 부호('- '·'1) ') 문단에만 채워지며,
56
+ * 마크다운 변환이 2칸/단계 선행 공백을 방출해 재생성 시 depth가 복원된다
57
+ */
58
+ listDepth?: number;
53
59
  }
54
60
  /** 추출된 이미지 바이너리 데이터 */
55
61
  interface ImageData {
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  sanitizeHref,
21
21
  stripDtd,
22
22
  toArrayBuffer
23
- } from "./chunk-KSVLQ5BC.js";
23
+ } from "./chunk-HOGJ5ALY.js";
24
24
  import {
25
25
  parsePageRange
26
26
  } from "./chunk-GE43BE46.js";
@@ -2069,8 +2069,9 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2069
2069
  if (footnote) text += ` (\uC8FC: ${footnote})`;
2070
2070
  cell2.text += (cell2.text ? "\n" : "") + text;
2071
2071
  const cellBlock = { type: "paragraph", text, pageNumber: ctx.sectionNum };
2072
- if (ctx.shared.kordocLayout === "default" && !ph?.prefix) {
2073
- const spans = extractRunSpans(el, ctx);
2072
+ const cellSpanMode = spanModeOf(ctx.shared.kordocLayout);
2073
+ if (cellSpanMode && !ph?.prefix) {
2074
+ const spans = extractRunSpans(el, ctx, cellSpanMode, cellSpanMode !== "kordoc");
2074
2075
  if (spans && spans.map((s) => s.text).join("").replace(/[ \t]+/g, " ").trim() === text) {
2075
2076
  cellBlock.spans = spans;
2076
2077
  }
@@ -2093,14 +2094,19 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2093
2094
  const eff = ind.left + Math.max(0, ind.intent);
2094
2095
  if (eff > 0) block.indent = eff;
2095
2096
  }
2096
- if (!headingLevel && ctx.shared.kordocLayout === "default") {
2097
+ if (ctx.shared.kordocLayout === "gongmun" && block.indent && /^(?:-|\d{1,3}\)) /.test(text)) {
2098
+ const depth2 = gongmunDepthFromIndent(el, block.indent, ctx);
2099
+ if (depth2) block.listDepth = depth2;
2100
+ }
2101
+ const spanMode = spanModeOf(ctx.shared.kordocLayout);
2102
+ if (!headingLevel && spanMode) {
2097
2103
  if (!ph?.prefix) {
2098
- const spans = extractRunSpans(el, ctx);
2104
+ const spans = extractRunSpans(el, ctx, spanMode, spanMode === "gongmun");
2099
2105
  if (spans && spans.map((s) => s.text).join("").replace(/[ \t]+/g, " ").trim() === text) {
2100
2106
  block.spans = spans;
2101
2107
  }
2102
2108
  }
2103
- if (el.getAttribute("paraPrIDRef") === KORDOC_PARA_QUOTE) block.quote = true;
2109
+ if (spanMode !== "foreign" && el.getAttribute("paraPrIDRef") === KORDOC_PARA_QUOTE) block.quote = true;
2104
2110
  }
2105
2111
  blocks.push(block);
2106
2112
  } else {
@@ -2223,8 +2229,15 @@ function collectSubListText(el, ctx, depth = 0) {
2223
2229
  if (tag === "p" || tag === "para") {
2224
2230
  const t = extractParagraphInfo(ch, ctx.styleMap, ctx).text;
2225
2231
  if (t) parts.push(t);
2232
+ const tbls = [];
2233
+ findTopLevelTbls(ch, tbls);
2234
+ for (const tbl2 of tbls) {
2235
+ const flat = flattenSubListTable(tbl2, ctx, depth);
2236
+ if (flat) parts.push(flat);
2237
+ }
2226
2238
  } else if (tag === "tbl") {
2227
- continue;
2239
+ const flat = flattenSubListTable(ch, ctx, depth);
2240
+ if (flat) parts.push(flat);
2228
2241
  } else {
2229
2242
  const t = collectSubListText(ch, ctx, depth + 1);
2230
2243
  if (t) parts.push(t);
@@ -2232,6 +2245,29 @@ function collectSubListText(el, ctx, depth = 0) {
2232
2245
  }
2233
2246
  return parts.join("\n").trim();
2234
2247
  }
2248
+ function flattenSubListTable(el, ctx, depth) {
2249
+ const sink = [];
2250
+ const st = { rows: [], currentRow: [], cell: null };
2251
+ walkSection(el, sink, st, [], ctx, depth + 1);
2252
+ let flat = convertTableToText(st.rows);
2253
+ if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
2254
+ return flat;
2255
+ }
2256
+ function findTopLevelTbls(el, out, depth = 0) {
2257
+ if (depth > MAX_XML_DEPTH) return;
2258
+ const kids2 = el.childNodes;
2259
+ if (!kids2) return;
2260
+ for (let i = 0; i < kids2.length; i++) {
2261
+ const ch = kids2[i];
2262
+ if (ch.nodeType !== 1) continue;
2263
+ const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
2264
+ if (tag === "tbl") {
2265
+ out.push(ch);
2266
+ continue;
2267
+ }
2268
+ findTopLevelTbls(ch, out, depth + 1);
2269
+ }
2270
+ }
2235
2271
  function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2236
2272
  if (depth > MAX_XML_DEPTH) return tableCtx;
2237
2273
  const children = node.childNodes;
@@ -2590,7 +2626,13 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2590
2626
  }
2591
2627
  var KORDOC_CHAR_CODE = "4";
2592
2628
  var KORDOC_PARA_QUOTE = "6";
2593
- function extractRunSpans(para2, ctx) {
2629
+ function spanModeOf(layout) {
2630
+ if (layout === "default") return "kordoc";
2631
+ if (layout === "gongmun") return "gongmun";
2632
+ if (!layout) return "foreign";
2633
+ return null;
2634
+ }
2635
+ function extractRunSpans(para2, ctx, mode, requireMixed) {
2594
2636
  const styleMap = ctx.styleMap;
2595
2637
  if (!styleMap) return null;
2596
2638
  const spans = [];
@@ -2627,7 +2669,7 @@ function extractRunSpans(para2, ctx) {
2627
2669
  const prId = child.getAttribute("charPrIDRef") ?? "";
2628
2670
  const cp = styleMap.charProperties.get(prId);
2629
2671
  const span = { text };
2630
- if (prId === KORDOC_CHAR_CODE) span.code = true;
2672
+ if (mode !== "foreign" && prId === KORDOC_CHAR_CODE) span.code = true;
2631
2673
  else {
2632
2674
  if (cp?.bold) span.bold = true;
2633
2675
  if (cp?.italic) span.italic = true;
@@ -2635,7 +2677,38 @@ function extractRunSpans(para2, ctx) {
2635
2677
  if (span.bold || span.italic || span.code) styled = true;
2636
2678
  spans.push(span);
2637
2679
  }
2638
- return styled && spans.length > 0 ? spans : null;
2680
+ if (!styled || spans.length === 0) return null;
2681
+ const merged = [];
2682
+ for (const s of spans) {
2683
+ const last = merged[merged.length - 1];
2684
+ if (last && !!last.bold === !!s.bold && !!last.italic === !!s.italic && !!last.code === !!s.code) {
2685
+ last.text += s.text;
2686
+ } else {
2687
+ merged.push(s);
2688
+ }
2689
+ }
2690
+ if (requireMixed && !merged.some((s) => !(s.bold || s.italic || s.code))) return null;
2691
+ return merged;
2692
+ }
2693
+ function gongmunDepthFromIndent(para2, left, ctx) {
2694
+ const styleMap = ctx.styleMap;
2695
+ if (!styleMap) return null;
2696
+ let unit = 0;
2697
+ const kids2 = para2.childNodes;
2698
+ for (let i = 0; i < (kids2?.length ?? 0); i++) {
2699
+ const child = kids2[i];
2700
+ if (child.nodeType !== 1) continue;
2701
+ const tag = (child.tagName || child.localName || "").replace(/^[^:]+:/, "");
2702
+ if (tag !== "run" && tag !== "r") continue;
2703
+ const size = styleMap.charProperties.get(child.getAttribute("charPrIDRef") ?? "")?.fontSize;
2704
+ if (size) unit = size * 100;
2705
+ break;
2706
+ }
2707
+ if (!unit) return null;
2708
+ const r = left / unit;
2709
+ const nearInt = Math.round(r);
2710
+ const depth = Math.abs(r - nearInt) < 0.2 ? nearInt : Math.round(2 * r - 1);
2711
+ return depth >= 1 && depth < 8 ? depth : null;
2639
2712
  }
2640
2713
 
2641
2714
  // src/hwpx/images.ts
@@ -29741,7 +29814,7 @@ async function parseHwp(buffer, options) {
29741
29814
  async function parsePdf(buffer, options) {
29742
29815
  let parsePdfDocument;
29743
29816
  try {
29744
- const mod = await import("./parser-TLCC67W6.js");
29817
+ const mod = await import("./parser-DMKHIV4E.js");
29745
29818
  parsePdfDocument = mod.parsePdfDocument;
29746
29819
  } catch {
29747
29820
  return {