kordoc 4.0.4 → 4.0.5

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 (47) hide show
  1. package/dist/{-Q4ZCVQFI.js → -QVHGOOCR.js} +7 -7
  2. package/dist/{chunk-KA5AN73R.js → chunk-6BABRVOJ.js} +2 -2
  3. package/dist/{chunk-ZJXR4PWY.js → chunk-6PED5OOG.js} +5 -4
  4. package/dist/{chunk-ZJXR4PWY.js.map → chunk-6PED5OOG.js.map} +1 -1
  5. package/dist/{chunk-NIW7CZYX.cjs → chunk-6R5FY47W.cjs} +5 -4
  6. package/dist/chunk-6R5FY47W.cjs.map +1 -0
  7. package/dist/{chunk-TXNRIVWA.js → chunk-6WDPB4SN.js} +3 -3
  8. package/dist/{chunk-KSVLQ5BC.js → chunk-FKK4K53F.js} +5 -4
  9. package/dist/{chunk-KSVLQ5BC.js.map → chunk-FKK4K53F.js.map} +1 -1
  10. package/dist/{chunk-S3KGEEBQ.js → chunk-OMERK4AW.js} +3 -3
  11. package/dist/{chunk-DKMKJMR6.js → chunk-QK2G34WE.js} +2 -2
  12. package/dist/{chunk-MLNHZN32.js → chunk-Z6Q3YG22.js} +58 -15
  13. package/dist/chunk-Z6Q3YG22.js.map +1 -0
  14. package/dist/{chunk-2RIOXYGA.js → chunk-ZGMMLYAL.js} +2 -2
  15. package/dist/cli.js +13 -13
  16. package/dist/index.cjs +406 -363
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +7 -1
  19. package/dist/index.d.ts +7 -1
  20. package/dist/index.js +53 -10
  21. package/dist/index.js.map +1 -1
  22. package/dist/mcp.js +10 -10
  23. package/dist/{parser-2ZUTCU2G.cjs → parser-2V5SPTU7.cjs} +14 -14
  24. package/dist/{parser-2ZUTCU2G.cjs.map → parser-2V5SPTU7.cjs.map} +1 -1
  25. package/dist/{parser-46JGSTPR.js → parser-3MAYZUJX.js} +3 -3
  26. package/dist/{parser-TLCC67W6.js → parser-YSHZC5FQ.js} +2 -2
  27. package/dist/{profile-io-MRVIJ5T4.js → profile-io-3EECPDHG.js} +3 -3
  28. package/dist/render-MJSQ4TG2.js +10 -0
  29. package/dist/seal-R3POFNOU.js +10 -0
  30. package/dist/{watch-NZNVJ4YD.js → watch-7MHSCKEQ.js} +7 -7
  31. package/package.json +1 -1
  32. package/dist/chunk-MLNHZN32.js.map +0 -1
  33. package/dist/chunk-NIW7CZYX.cjs.map +0 -1
  34. package/dist/render-TTOG6CHW.js +0 -10
  35. package/dist/seal-NMLZ3M3K.js +0 -10
  36. /package/dist/{-Q4ZCVQFI.js.map → -QVHGOOCR.js.map} +0 -0
  37. /package/dist/{chunk-KA5AN73R.js.map → chunk-6BABRVOJ.js.map} +0 -0
  38. /package/dist/{chunk-TXNRIVWA.js.map → chunk-6WDPB4SN.js.map} +0 -0
  39. /package/dist/{chunk-S3KGEEBQ.js.map → chunk-OMERK4AW.js.map} +0 -0
  40. /package/dist/{chunk-DKMKJMR6.js.map → chunk-QK2G34WE.js.map} +0 -0
  41. /package/dist/{chunk-2RIOXYGA.js.map → chunk-ZGMMLYAL.js.map} +0 -0
  42. /package/dist/{parser-46JGSTPR.js.map → parser-3MAYZUJX.js.map} +0 -0
  43. /package/dist/{parser-TLCC67W6.js.map → parser-YSHZC5FQ.js.map} +0 -0
  44. /package/dist/{profile-io-MRVIJ5T4.js.map → profile-io-3EECPDHG.js.map} +0 -0
  45. /package/dist/{render-TTOG6CHW.js.map → render-MJSQ4TG2.js.map} +0 -0
  46. /package/dist/{seal-NMLZ3M3K.js.map → seal-R3POFNOU.js.map} +0 -0
  47. /package/dist/{watch-NZNVJ4YD.js.map → watch-7MHSCKEQ.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-FKK4K53F.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 {
@@ -2590,7 +2596,13 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2590
2596
  }
2591
2597
  var KORDOC_CHAR_CODE = "4";
2592
2598
  var KORDOC_PARA_QUOTE = "6";
2593
- function extractRunSpans(para2, ctx) {
2599
+ function spanModeOf(layout) {
2600
+ if (layout === "default") return "kordoc";
2601
+ if (layout === "gongmun") return "gongmun";
2602
+ if (!layout) return "foreign";
2603
+ return null;
2604
+ }
2605
+ function extractRunSpans(para2, ctx, mode, requireMixed) {
2594
2606
  const styleMap = ctx.styleMap;
2595
2607
  if (!styleMap) return null;
2596
2608
  const spans = [];
@@ -2627,7 +2639,7 @@ function extractRunSpans(para2, ctx) {
2627
2639
  const prId = child.getAttribute("charPrIDRef") ?? "";
2628
2640
  const cp = styleMap.charProperties.get(prId);
2629
2641
  const span = { text };
2630
- if (prId === KORDOC_CHAR_CODE) span.code = true;
2642
+ if (mode !== "foreign" && prId === KORDOC_CHAR_CODE) span.code = true;
2631
2643
  else {
2632
2644
  if (cp?.bold) span.bold = true;
2633
2645
  if (cp?.italic) span.italic = true;
@@ -2635,7 +2647,38 @@ function extractRunSpans(para2, ctx) {
2635
2647
  if (span.bold || span.italic || span.code) styled = true;
2636
2648
  spans.push(span);
2637
2649
  }
2638
- return styled && spans.length > 0 ? spans : null;
2650
+ if (!styled || spans.length === 0) return null;
2651
+ const merged = [];
2652
+ for (const s of spans) {
2653
+ const last = merged[merged.length - 1];
2654
+ if (last && !!last.bold === !!s.bold && !!last.italic === !!s.italic && !!last.code === !!s.code) {
2655
+ last.text += s.text;
2656
+ } else {
2657
+ merged.push(s);
2658
+ }
2659
+ }
2660
+ if (requireMixed && !merged.some((s) => !(s.bold || s.italic || s.code))) return null;
2661
+ return merged;
2662
+ }
2663
+ function gongmunDepthFromIndent(para2, left, ctx) {
2664
+ const styleMap = ctx.styleMap;
2665
+ if (!styleMap) return null;
2666
+ let unit = 0;
2667
+ const kids2 = para2.childNodes;
2668
+ for (let i = 0; i < (kids2?.length ?? 0); i++) {
2669
+ const child = kids2[i];
2670
+ if (child.nodeType !== 1) continue;
2671
+ const tag = (child.tagName || child.localName || "").replace(/^[^:]+:/, "");
2672
+ if (tag !== "run" && tag !== "r") continue;
2673
+ const size = styleMap.charProperties.get(child.getAttribute("charPrIDRef") ?? "")?.fontSize;
2674
+ if (size) unit = size * 100;
2675
+ break;
2676
+ }
2677
+ if (!unit) return null;
2678
+ const r = left / unit;
2679
+ const nearInt = Math.round(r);
2680
+ const depth = Math.abs(r - nearInt) < 0.2 ? nearInt : Math.round(2 * r - 1);
2681
+ return depth >= 1 && depth < 8 ? depth : null;
2639
2682
  }
2640
2683
 
2641
2684
  // src/hwpx/images.ts
@@ -29741,7 +29784,7 @@ async function parseHwp(buffer, options) {
29741
29784
  async function parsePdf(buffer, options) {
29742
29785
  let parsePdfDocument;
29743
29786
  try {
29744
- const mod = await import("./parser-TLCC67W6.js");
29787
+ const mod = await import("./parser-YSHZC5FQ.js");
29745
29788
  parsePdfDocument = mod.parsePdfDocument;
29746
29789
  } catch {
29747
29790
  return {