kordoc 3.1.1 → 3.2.1

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 (60) hide show
  1. package/README.md +584 -559
  2. package/dist/{-UCE73NNK.js → -NMUBDTYV.js} +4 -4
  3. package/dist/chunk-DCZVOIEO.cjs.map +1 -1
  4. package/dist/{chunk-KR6DSGM7.js → chunk-F4A7OTBT.js} +2 -2
  5. package/dist/chunk-F4A7OTBT.js.map +1 -0
  6. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  7. package/dist/{chunk-VMUP5WPI.js → chunk-LPKAF45D.js} +257 -43
  8. package/dist/chunk-LPKAF45D.js.map +1 -0
  9. package/dist/{chunk-5CJGKKMZ.js → chunk-MEPHGCPQ.js} +1 -1
  10. package/dist/chunk-MEPHGCPQ.js.map +1 -0
  11. package/dist/chunk-MOL7MDBG.js +0 -0
  12. package/dist/{chunk-ZZNSI4GV.js → chunk-Q7IWG4E3.js} +2 -2
  13. package/dist/chunk-Q7IWG4E3.js.map +1 -0
  14. package/dist/{chunk-FJON4QNB.cjs → chunk-ZY524HB6.cjs} +2 -2
  15. package/dist/chunk-ZY524HB6.cjs.map +1 -0
  16. package/dist/cli.js +72 -5
  17. package/dist/cli.js.map +1 -1
  18. package/dist/{detect-PJZMUL2Z.js → detect-RI2MQ33K.js} +2 -2
  19. package/dist/formula-5NKVS2LR.cjs.map +1 -1
  20. package/dist/formula-JCNF43NE.js +0 -0
  21. package/dist/index.cjs +419 -205
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +44 -2
  24. package/dist/index.d.ts +44 -2
  25. package/dist/index.js +255 -41
  26. package/dist/index.js.map +1 -1
  27. package/dist/mcp.js +5 -5
  28. package/dist/mcp.js.map +1 -1
  29. package/dist/page-range-737B4EZW.js +0 -0
  30. package/dist/page-range-P7SDW6LR.cjs.map +1 -1
  31. package/dist/{parser-XULVNDMN.cjs → parser-CV3FOVOS.cjs} +15 -15
  32. package/dist/parser-CV3FOVOS.cjs.map +1 -0
  33. package/dist/{parser-4L7UFVEP.js → parser-HC5NXB3F.js} +3 -3
  34. package/dist/parser-HC5NXB3F.js.map +1 -0
  35. package/dist/{parser-QTJL6IQY.js → parser-ZWGQCMRS.js} +3 -3
  36. package/dist/parser-ZWGQCMRS.js.map +1 -0
  37. package/dist/{provider-H4WWSPOV.js → provider-4ZJKV3DC.js} +1 -1
  38. package/dist/provider-4ZJKV3DC.js.map +1 -0
  39. package/dist/{provider-7H4CPZYS.js → provider-AKROB7WQ.js} +1 -1
  40. package/dist/provider-AKROB7WQ.js.map +1 -0
  41. package/dist/{provider-5K7O3Z2O.cjs → provider-G4C2V2PD.cjs} +1 -1
  42. package/dist/provider-G4C2V2PD.cjs.map +1 -0
  43. package/dist/setup-57FB3LSP.js +0 -0
  44. package/dist/{watch-FPDSHB23.js → watch-IUEQDWC3.js} +4 -4
  45. package/dist/watch-IUEQDWC3.js.map +1 -0
  46. package/package.json +98 -98
  47. package/dist/chunk-5CJGKKMZ.js.map +0 -1
  48. package/dist/chunk-FJON4QNB.cjs.map +0 -1
  49. package/dist/chunk-KR6DSGM7.js.map +0 -1
  50. package/dist/chunk-VMUP5WPI.js.map +0 -1
  51. package/dist/chunk-ZZNSI4GV.js.map +0 -1
  52. package/dist/parser-4L7UFVEP.js.map +0 -1
  53. package/dist/parser-QTJL6IQY.js.map +0 -1
  54. package/dist/parser-XULVNDMN.cjs.map +0 -1
  55. package/dist/provider-5K7O3Z2O.cjs.map +0 -1
  56. package/dist/provider-7H4CPZYS.js.map +0 -1
  57. package/dist/provider-H4WWSPOV.js.map +0 -1
  58. package/dist/watch-FPDSHB23.js.map +0 -1
  59. /package/dist/{-UCE73NNK.js.map → -NMUBDTYV.js.map} +0 -0
  60. /package/dist/{detect-PJZMUL2Z.js.map → detect-RI2MQ33K.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  detectOle2Format,
5
5
  detectZipFormat,
6
6
  parseLenientCfb
7
- } from "./chunk-5CJGKKMZ.js";
7
+ } from "./chunk-MEPHGCPQ.js";
8
8
  import {
9
9
  HEADING_RATIO_H1,
10
10
  HEADING_RATIO_H2,
@@ -23,7 +23,7 @@ import {
23
23
  sanitizeHref,
24
24
  stripDtd,
25
25
  toArrayBuffer
26
- } from "./chunk-KR6DSGM7.js";
26
+ } from "./chunk-F4A7OTBT.js";
27
27
  import {
28
28
  parsePageRange
29
29
  } from "./chunk-MOL7MDBG.js";
@@ -19364,6 +19364,15 @@ function buildRangeSplices(para, xml, start, end, replacement) {
19364
19364
  }
19365
19365
  return placed ? splices : null;
19366
19366
  }
19367
+ function allLinesegRemovalSplices(xml) {
19368
+ const segRe = /<(\w+:)?linesegarray\b[^>]*?(?:\/>|>[\s\S]*?<\/\1linesegarray>)/g;
19369
+ const splices = [];
19370
+ let m;
19371
+ while ((m = segRe.exec(xml)) !== null) {
19372
+ splices.push({ start: m.index, end: m.index + m[0].length, replacement: "" });
19373
+ }
19374
+ return splices;
19375
+ }
19367
19376
  function applySplices(xml, splices) {
19368
19377
  const sorted = [...splices].sort((a, b) => a.start - b.start);
19369
19378
  for (let i = 1; i < sorted.length; i++) {
@@ -19760,9 +19769,115 @@ async function fillHwpx(hwpxBuffer, values) {
19760
19769
 
19761
19770
  // src/hwpx/generator.ts
19762
19771
  import JSZip5 from "jszip";
19772
+
19773
+ // src/hwpx/gongmun.ts
19774
+ var OFFICIAL_MARGINS = { top: 20, bottom: 10, left: 20, right: 20 };
19775
+ var PRESET_DEFAULTS = {
19776
+ official: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
19777
+ report: { bodyPt: 15, lineSpacing: 160, numbering: "report" },
19778
+ plan: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
19779
+ notice: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
19780
+ minutes: { bodyPt: 14, lineSpacing: 130, numbering: "standard" }
19781
+ };
19782
+ function resolveGongmun(opts) {
19783
+ const preset = opts.preset ?? "official";
19784
+ const d = PRESET_DEFAULTS[preset];
19785
+ const bodyPt = opts.bodyPt ?? d.bodyPt;
19786
+ return {
19787
+ preset,
19788
+ bodyFont: opts.bodyFont ?? "myeongjo",
19789
+ bodyHeight: Math.round(bodyPt * 100),
19790
+ lineSpacing: opts.lineSpacing ?? d.lineSpacing,
19791
+ numbering: opts.numbering ?? d.numbering,
19792
+ margins: opts.margins ?? OFFICIAL_MARGINS,
19793
+ centerTitle: opts.centerTitle ?? true
19794
+ };
19795
+ }
19796
+ var HANGUL_INITIALS = [0, 2, 3, 5, 6, 7, 9, 11, 12, 14, 15, 16, 17, 18];
19797
+ var HANGUL_MEDIALS = [0, 4, 8, 13, 18, 20];
19798
+ function hangulOrdinal(n) {
19799
+ const cols = HANGUL_INITIALS.length;
19800
+ const vowel = HANGUL_MEDIALS[Math.min(Math.floor(n / cols), HANGUL_MEDIALS.length - 1)];
19801
+ const init = HANGUL_INITIALS[n % cols];
19802
+ return String.fromCodePoint(44032 + init * 588 + vowel * 28);
19803
+ }
19804
+ function circledNumber(n) {
19805
+ return String.fromCodePoint(9312 + n % 20);
19806
+ }
19807
+ function circledHangul(n) {
19808
+ return String.fromCodePoint(12910 + n % 14);
19809
+ }
19810
+ var REPORT_BULLETS = ["\u25A1", "\u25CB", "-", "\u318D"];
19811
+ function standardMarker(depth, n) {
19812
+ switch (depth) {
19813
+ case 0:
19814
+ return `${n + 1}.`;
19815
+ case 1:
19816
+ return `${hangulOrdinal(n)}.`;
19817
+ case 2:
19818
+ return `${n + 1})`;
19819
+ case 3:
19820
+ return `${hangulOrdinal(n)})`;
19821
+ case 4:
19822
+ return `(${n + 1})`;
19823
+ case 5:
19824
+ return `(${hangulOrdinal(n)})`;
19825
+ case 6:
19826
+ return circledNumber(n);
19827
+ case 7:
19828
+ return circledHangul(n);
19829
+ default:
19830
+ return circledHangul(n);
19831
+ }
19832
+ }
19833
+ function reportMarker(depth) {
19834
+ return REPORT_BULLETS[Math.min(depth, REPORT_BULLETS.length - 1)];
19835
+ }
19836
+ function levelIndent(depth, bodyHeight, numbering) {
19837
+ const ta = bodyHeight / 2;
19838
+ const markerTa = numbering === "standard" && (depth === 4 || depth === 5) ? 3 : 2;
19839
+ const hang = Math.round((markerTa + 1) * ta);
19840
+ return { left: Math.round(depth * bodyHeight), indent: -hang };
19841
+ }
19842
+ function computeSuppression(depths) {
19843
+ const counts = /* @__PURE__ */ new Map();
19844
+ const keys = [];
19845
+ const path = [];
19846
+ for (const depth of depths) {
19847
+ path.length = depth + 1;
19848
+ path[depth] = (path[depth] ?? 0) + 1;
19849
+ const parentKey = path.slice(0, depth).join(".") + "|" + depth;
19850
+ keys.push(parentKey);
19851
+ counts.set(parentKey, (counts.get(parentKey) ?? 0) + 1);
19852
+ }
19853
+ return keys.map((k) => (counts.get(k) ?? 0) <= 1);
19854
+ }
19855
+ var GongmunNumberer = class {
19856
+ constructor(numbering) {
19857
+ this.numbering = numbering;
19858
+ }
19859
+ counts = [];
19860
+ /** depth 항목 하나에 대한 마커. suppress=true면 빈 문자열(부호 없음) */
19861
+ next(depth, suppress) {
19862
+ this.counts.length = depth + 1;
19863
+ const n = this.counts[depth] ?? 0;
19864
+ this.counts[depth] = n + 1;
19865
+ if (suppress) return "";
19866
+ return this.numbering === "report" ? reportMarker(depth) : standardMarker(depth, n);
19867
+ }
19868
+ reset() {
19869
+ this.counts = [];
19870
+ }
19871
+ };
19872
+ function mmToHwpunit(mm) {
19873
+ return Math.round(mm * 7200 / 25.4);
19874
+ }
19875
+
19876
+ // src/hwpx/generator.ts
19763
19877
  var NS_SECTION = "http://www.hancom.co.kr/hwpml/2011/section";
19764
19878
  var NS_PARA = "http://www.hancom.co.kr/hwpml/2011/paragraph";
19765
19879
  var NS_HEAD = "http://www.hancom.co.kr/hwpml/2011/head";
19880
+ var NS_CORE = "http://www.hancom.co.kr/hwpml/2011/core";
19766
19881
  var NS_OPF = "http://www.idpf.org/2007/opf/";
19767
19882
  var NS_HPF = "http://www.hancom.co.kr/schema/2011/hpf";
19768
19883
  var NS_OCF = "urn:oasis:names:tc:opendocument:xmlns:container";
@@ -19802,13 +19917,14 @@ function resolveTheme(theme) {
19802
19917
  }
19803
19918
  async function markdownToHwpx(markdown, options) {
19804
19919
  const theme = resolveTheme(options?.theme);
19920
+ const gongmun = options?.gongmun ? resolveGongmun(options.gongmun) : null;
19805
19921
  const blocks = parseMarkdownToBlocks(markdown);
19806
- const sectionXml = blocksToSectionXml(blocks, theme);
19922
+ const sectionXml = blocksToSectionXml(blocks, theme, gongmun);
19807
19923
  const zip = new JSZip5();
19808
19924
  zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
19809
19925
  zip.file("META-INF/container.xml", generateContainerXml());
19810
19926
  zip.file("Contents/content.hpf", generateManifest());
19811
- zip.file("Contents/header.xml", generateHeaderXml(theme));
19927
+ zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun));
19812
19928
  zip.file("Contents/section0.xml", sectionXml);
19813
19929
  zip.file("Preview/PrvText.txt", buildPrvText(blocks));
19814
19930
  return await zip.generateAsync({ type: "arraybuffer" });
@@ -20001,25 +20117,95 @@ function charPr(id, height, bold, italic, fontId = 0, textColor = DEFAULT_TEXT_C
20001
20117
  </hh:charPr>`;
20002
20118
  }
20003
20119
  function paraPr(id, opts = {}) {
20004
- const { align = "JUSTIFY", spaceBefore = 0, spaceAfter = 0, lineSpacing = 160, indent = 0 } = opts;
20120
+ const { align = "JUSTIFY", spaceBefore = 0, spaceAfter = 0, lineSpacing = 160, indent = 0, left = 0 } = opts;
20005
20121
  return ` <hh:paraPr id="${id}" tabPrIDRef="0" condense="0" fontLineHeight="0" snapToGrid="1" suppressLineNumbers="0" checked="0" textDir="AUTO">
20006
20122
  <hh:align horizontal="${align}" vertical="BASELINE"/>
20007
20123
  <hh:heading type="NONE" idRef="0" level="0"/>
20008
20124
  <hh:breakSetting breakLatinWord="KEEP_WORD" breakNonLatinWord="BREAK_WORD" widowOrphan="0" keepWithNext="0" keepLines="0" pageBreakBefore="0" lineWrap="BREAK"/>
20009
20125
  <hh:autoSpacing eAsianEng="0" eAsianNum="0"/>
20010
- <hh:margin indent="${indent}" left="0" right="0" prev="${spaceBefore}" next="${spaceAfter}"/>
20126
+ <hh:margin><hc:intent value="${indent}" unit="HWPUNIT"/><hc:left value="${left}" unit="HWPUNIT"/><hc:right value="0" unit="HWPUNIT"/><hc:prev value="${spaceBefore}" unit="HWPUNIT"/><hc:next value="${spaceAfter}" unit="HWPUNIT"/></hh:margin>
20011
20127
  <hh:lineSpacing type="PERCENT" value="${lineSpacing}"/>
20012
20128
  <hh:border borderFillIDRef="0" offsetLeft="0" offsetRight="0" offsetTop="0" offsetBottom="0" connect="0" ignoreMargin="0"/>
20013
20129
  </hh:paraPr>`;
20014
20130
  }
20015
- function generateHeaderXml(theme) {
20131
+ var GONGMUN_LIST_BASE = 8;
20132
+ var GONGMUN_LIST_LEVELS = 8;
20133
+ var GONGMUN_CENTER = GONGMUN_LIST_BASE + GONGMUN_LIST_LEVELS;
20134
+ function buildCharProperties(theme, gongmun) {
20135
+ let body = 1e3, code = 900, h1 = 1800, h2 = 1400, h3 = 1200, h4 = 1100;
20136
+ if (gongmun) {
20137
+ body = gongmun.bodyHeight;
20138
+ code = Math.max(body - 200, 900);
20139
+ h1 = gongmun.preset === "report" || gongmun.preset === "plan" ? 2e3 : 1700;
20140
+ h2 = 1600;
20141
+ h3 = body;
20142
+ h4 = Math.max(body - 100, 1300);
20143
+ }
20144
+ const rows = [
20145
+ charPr(0, body, false, false, 0, theme.body),
20146
+ charPr(1, body, true, false, 0, theme.body),
20147
+ charPr(2, body, false, true, 0, theme.body),
20148
+ charPr(3, body, true, true, 0, theme.body),
20149
+ charPr(4, code, false, false, 1),
20150
+ charPr(5, h1, true, false, 1, theme.h1),
20151
+ charPr(6, h2, true, false, 1, theme.h2),
20152
+ charPr(7, h3, true, false, 1, theme.h3),
20153
+ charPr(8, h4, true, false, 1, theme.h4),
20154
+ charPr(CHAR_TABLE_HEADER, body, theme.tableHeaderBold, false, 0, theme.tableHeader),
20155
+ charPr(CHAR_QUOTE, body, false, true, 0, theme.quote)
20156
+ ];
20157
+ return `<hh:charProperties itemCnt="${rows.length}">
20158
+ ${rows.join("\n")}
20159
+ </hh:charProperties>`;
20160
+ }
20161
+ function buildParaProperties(gongmun) {
20162
+ if (!gongmun) {
20163
+ const base2 = [
20164
+ paraPr(0),
20165
+ paraPr(1, { align: "LEFT", spaceBefore: 800, spaceAfter: 200, lineSpacing: 180 }),
20166
+ paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: 170 }),
20167
+ paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: 160 }),
20168
+ paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: 160 }),
20169
+ paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 }),
20170
+ paraPr(6, { align: "LEFT", lineSpacing: 150, indent: 600 }),
20171
+ paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })
20172
+ ];
20173
+ return `<hh:paraProperties itemCnt="${base2.length}">
20174
+ ${base2.join("\n")}
20175
+ </hh:paraProperties>`;
20176
+ }
20177
+ const ls = gongmun.lineSpacing;
20178
+ const titleAlign = gongmun.centerTitle ? "CENTER" : "LEFT";
20179
+ const base = [
20180
+ paraPr(0, { lineSpacing: ls }),
20181
+ paraPr(1, { align: titleAlign, spaceBefore: 400, spaceAfter: 400, lineSpacing: ls }),
20182
+ paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: ls }),
20183
+ paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: ls }),
20184
+ paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: ls }),
20185
+ paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 }),
20186
+ paraPr(6, { align: "LEFT", lineSpacing: ls, indent: 600 }),
20187
+ paraPr(7, { align: "LEFT", lineSpacing: ls, indent: 600 })
20188
+ ];
20189
+ for (let d = 0; d < GONGMUN_LIST_LEVELS; d++) {
20190
+ const { left, indent } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering);
20191
+ base.push(paraPr(GONGMUN_LIST_BASE + d, { align: "JUSTIFY", lineSpacing: ls, left, indent }));
20192
+ }
20193
+ base.push(paraPr(GONGMUN_CENTER, { align: "CENTER", lineSpacing: ls }));
20194
+ return `<hh:paraProperties itemCnt="${base.length}">
20195
+ ${base.join("\n")}
20196
+ </hh:paraProperties>`;
20197
+ }
20198
+ function generateHeaderXml(theme, gongmun) {
20199
+ const bodyFace = gongmun?.bodyFont === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
20200
+ const charPropsXml = buildCharProperties(theme, gongmun);
20201
+ const paraPropsXml = buildParaProperties(gongmun);
20016
20202
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
20017
- <hh:head xmlns:hh="${NS_HEAD}" xmlns:hp="${NS_PARA}" version="1.4" secCnt="1">
20203
+ <hh:head xmlns:hh="${NS_HEAD}" xmlns:hp="${NS_PARA}" xmlns:hc="${NS_CORE}" version="1.4" secCnt="1">
20018
20204
  <hh:beginNum page="1" footnote="1" endnote="1" pic="1" tbl="1" equation="1"/>
20019
20205
  <hh:refList>
20020
20206
  <hh:fontfaces itemCnt="7">
20021
20207
  <hh:fontface lang="HANGUL" fontCnt="3">
20022
- <hh:font id="0" face="\uD568\uCD08\uB86C\uBC14\uD0D5" type="TTF" isEmbedded="0">
20208
+ <hh:font id="0" face="${bodyFace}" type="TTF" isEmbedded="0">
20023
20209
  <hh:typeInfo familyType="FCAT_GOTHIC" weight="6" proportion="4" contrast="0" strokeVariation="1" armStyle="1" letterform="1" midline="1" xHeight="1"/>
20024
20210
  </hh:font>
20025
20211
  <hh:font id="1" face="\uD568\uCD08\uB86C\uB3CB\uC6C0" type="TTF" isEmbedded="0">
@@ -20088,32 +20274,11 @@ function generateHeaderXml(theme) {
20088
20274
  <hh:fillInfo/>
20089
20275
  </hh:borderFill>
20090
20276
  </hh:borderFills>
20091
- <hh:charProperties itemCnt="11">
20092
- ${charPr(0, 1e3, false, false, 0, theme.body)}
20093
- ${charPr(1, 1e3, true, false, 0, theme.body)}
20094
- ${charPr(2, 1e3, false, true, 0, theme.body)}
20095
- ${charPr(3, 1e3, true, true, 0, theme.body)}
20096
- ${charPr(4, 900, false, false, 1)}
20097
- ${charPr(5, 1800, true, false, 1, theme.h1)}
20098
- ${charPr(6, 1400, true, false, 1, theme.h2)}
20099
- ${charPr(7, 1200, true, false, 1, theme.h3)}
20100
- ${charPr(8, 1100, true, false, 1, theme.h4)}
20101
- ${charPr(CHAR_TABLE_HEADER, 1e3, theme.tableHeaderBold, false, 0, theme.tableHeader)}
20102
- ${charPr(CHAR_QUOTE, 1e3, false, true, 0, theme.quote)}
20103
- </hh:charProperties>
20277
+ ${charPropsXml}
20104
20278
  <hh:tabProperties itemCnt="0"/>
20105
20279
  <hh:numberings itemCnt="0"/>
20106
20280
  <hh:bullets itemCnt="0"/>
20107
- <hh:paraProperties itemCnt="8">
20108
- ${paraPr(0)}
20109
- ${paraPr(1, { align: "LEFT", spaceBefore: 800, spaceAfter: 200, lineSpacing: 180 })}
20110
- ${paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: 170 })}
20111
- ${paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: 160 })}
20112
- ${paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: 160 })}
20113
- ${paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 })}
20114
- ${paraPr(6, { align: "LEFT", lineSpacing: 150, indent: 600 })}
20115
- ${paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })}
20116
- </hh:paraProperties>
20281
+ ${paraPropsXml}
20117
20282
  <hh:styles itemCnt="1">
20118
20283
  <hh:style id="0" type="PARA" name="\uBC14\uD0D5\uAE00" engName="Normal" paraPrIDRef="0" charPrIDRef="0" nextStyleIDRef="0" langIDRef="1042" lockForm="0"/>
20119
20284
  </hh:styles>
@@ -20121,8 +20286,16 @@ ${paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })}
20121
20286
  <hh:compatibleDocument targetProgram="HWP2018"/>
20122
20287
  </hh:head>`;
20123
20288
  }
20124
- function generateSecPr() {
20125
- return `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="0" memoShapeIDRef="0" textVerticalWidthHead="0" masterPageCnt="0"><hp:grid lineGrid="0" charGrid="0" wonggojiFormat="0"/><hp:startNum pageStartsOn="BOTH" page="0" pic="0" tbl="0" equation="0"/><hp:visibility hideFirstHeader="0" hideFirstFooter="0" hideFirstMasterPage="0" border="SHOW_ALL" fill="SHOW_ALL" hideFirstPageNum="0" hideFirstEmptyLine="0" showLineNumber="0"/><hp:pagePr landscape="WIDELY" width="59528" height="84188" gutterType="LEFT_ONLY"><hp:margin header="2835" footer="2835" gutter="0" left="5670" right="4252" top="8504" bottom="4252"/></hp:pagePr><hp:footNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="-1" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="283" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="EACH_COLUMN" beneathText="0"/></hp:footNotePr><hp:endNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="14692344" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="0" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="END_OF_DOCUMENT" beneathText="0"/></hp:endNotePr></hp:secPr>`;
20289
+ function generateSecPr(gongmun) {
20290
+ const m = gongmun ? {
20291
+ top: mmToHwpunit(gongmun.margins.top),
20292
+ bottom: mmToHwpunit(gongmun.margins.bottom),
20293
+ left: mmToHwpunit(gongmun.margins.left),
20294
+ right: mmToHwpunit(gongmun.margins.right),
20295
+ header: 0,
20296
+ footer: 0
20297
+ } : { top: 8504, bottom: 4252, left: 5670, right: 4252, header: 2835, footer: 2835 };
20298
+ return `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="0" memoShapeIDRef="0" textVerticalWidthHead="0" masterPageCnt="0"><hp:grid lineGrid="0" charGrid="0" wonggojiFormat="0"/><hp:startNum pageStartsOn="BOTH" page="0" pic="0" tbl="0" equation="0"/><hp:visibility hideFirstHeader="0" hideFirstFooter="0" hideFirstMasterPage="0" border="SHOW_ALL" fill="SHOW_ALL" hideFirstPageNum="0" hideFirstEmptyLine="0" showLineNumber="0"/><hp:pagePr landscape="WIDELY" width="59528" height="84188" gutterType="LEFT_ONLY"><hp:margin header="${m.header}" footer="${m.footer}" gutter="0" left="${m.left}" right="${m.right}" top="${m.top}" bottom="${m.bottom}"/></hp:pagePr><hp:footNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="-1" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="283" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="EACH_COLUMN" beneathText="0"/></hp:footNotePr><hp:endNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="14692344" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="0" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="END_OF_DOCUMENT" beneathText="0"/></hp:endNotePr></hp:secPr>`;
20126
20299
  }
20127
20300
  var TABLE_ID_BASE = 1e3;
20128
20301
  var tableIdCounter = TABLE_ID_BASE;
@@ -20153,12 +20326,37 @@ function generateTable(rows, theme) {
20153
20326
  const tbl = `<hp:tbl id="${tblId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="0" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="1" noShading="0">${tblInner}</hp:tbl>`;
20154
20327
  return `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${tbl}</hp:run></hp:p>`;
20155
20328
  }
20156
- function blocksToSectionXml(blocks, theme) {
20329
+ function precomputeGongmunList(blocks, gongmun) {
20330
+ const result = /* @__PURE__ */ new Map();
20331
+ let i = 0;
20332
+ while (i < blocks.length) {
20333
+ if (blocks[i].type !== "list_item") {
20334
+ i++;
20335
+ continue;
20336
+ }
20337
+ const run = [];
20338
+ while (i < blocks.length && blocks[i].type === "list_item") {
20339
+ run.push(i);
20340
+ i++;
20341
+ }
20342
+ const depths = run.map((bi) => Math.min(Math.max(blocks[bi].indent || 0, 0), GONGMUN_LIST_LEVELS - 1));
20343
+ const suppress = gongmun.numbering === "standard" ? computeSuppression(depths) : depths.map(() => false);
20344
+ const numberer = new GongmunNumberer(gongmun.numbering);
20345
+ run.forEach((bi, k) => {
20346
+ const marker = numberer.next(depths[k], suppress[k]);
20347
+ result.set(bi, { marker, depth: depths[k] });
20348
+ });
20349
+ }
20350
+ return result;
20351
+ }
20352
+ function blocksToSectionXml(blocks, theme, gongmun) {
20157
20353
  const paraXmls = [];
20158
20354
  let isFirst = true;
20159
20355
  const orderedCounters = {};
20160
20356
  let prevWasOrdered = false;
20161
- for (const block of blocks) {
20357
+ const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
20358
+ for (let blockIdx = 0; blockIdx < blocks.length; blockIdx++) {
20359
+ const block = blocks[blockIdx];
20162
20360
  let xml = "";
20163
20361
  if (block.type !== "list_item" || !block.ordered) {
20164
20362
  if (prevWasOrdered) {
@@ -20173,9 +20371,15 @@ function blocksToSectionXml(blocks, theme) {
20173
20371
  xml = generateParagraph(block.text || "", pId, cId);
20174
20372
  break;
20175
20373
  }
20176
- case "paragraph":
20177
- xml = generateParagraph(block.text || "");
20374
+ case "paragraph": {
20375
+ const ctr = gongmun && /^<center>([\s\S]*)<\/center>$/i.exec((block.text || "").trim());
20376
+ if (ctr) {
20377
+ xml = generateParagraph(ctr[1].trim(), GONGMUN_CENTER);
20378
+ } else {
20379
+ xml = generateParagraph(block.text || "");
20380
+ }
20178
20381
  break;
20382
+ }
20179
20383
  case "code_block": {
20180
20384
  const codeLines = (block.text || "").split("\n");
20181
20385
  xml = codeLines.map((line) => generateParagraph(line || " ", PARA_CODE)).join("\n ");
@@ -20189,6 +20393,15 @@ function blocksToSectionXml(blocks, theme) {
20189
20393
  );
20190
20394
  break;
20191
20395
  case "list_item": {
20396
+ if (gongmun && gongmunList) {
20397
+ const info = gongmunList.get(blockIdx);
20398
+ const depth = info?.depth ?? 0;
20399
+ const marker2 = info?.marker ?? "";
20400
+ const content = block.text || "";
20401
+ const text = marker2 ? `${marker2} ${content}` : content;
20402
+ xml = generateParagraph(text, GONGMUN_LIST_BASE + depth);
20403
+ break;
20404
+ }
20192
20405
  const indent = block.indent || 0;
20193
20406
  let marker;
20194
20407
  if (block.ordered) {
@@ -20215,7 +20428,7 @@ function blocksToSectionXml(blocks, theme) {
20215
20428
  case "table":
20216
20429
  if (block.rows) {
20217
20430
  if (isFirst) {
20218
- const secRun = `<hp:run charPrIDRef="0">${generateSecPr()}<hp:t></hp:t></hp:run>`;
20431
+ const secRun = `<hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run>`;
20219
20432
  paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
20220
20433
  isFirst = false;
20221
20434
  }
@@ -20227,14 +20440,14 @@ function blocksToSectionXml(blocks, theme) {
20227
20440
  if (isFirst && block.type !== "table") {
20228
20441
  xml = xml.replace(
20229
20442
  /<hp:run charPrIDRef="(\d+)">/,
20230
- `<hp:run charPrIDRef="$1">${generateSecPr()}`
20443
+ `<hp:run charPrIDRef="$1">${generateSecPr(gongmun)}`
20231
20444
  );
20232
20445
  isFirst = false;
20233
20446
  }
20234
20447
  paraXmls.push(xml);
20235
20448
  }
20236
20449
  if (paraXmls.length === 0) {
20237
- paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${generateSecPr()}<hp:t></hp:t></hp:run></hp:p>`);
20450
+ paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run></hp:p>`);
20238
20451
  }
20239
20452
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
20240
20453
  <hs:sec xmlns:hs="${NS_SECTION}" xmlns:hp="${NS_PARA}">
@@ -21030,6 +21243,7 @@ async function patchHwpx(original, editedMarkdown, options) {
21030
21243
  try {
21031
21244
  for (let i = 0; i < scans.length; i++) {
21032
21245
  if (sectionSplices[i].length === 0) continue;
21246
+ sectionSplices[i].push(...allLinesegRemovalSplices(scans[i].xml));
21033
21247
  const newXml = applySplices(scans[i].xml, sectionSplices[i]);
21034
21248
  replacements.set(sectionPaths[i], encoder.encode(newXml));
21035
21249
  }
@@ -22747,7 +22961,7 @@ async function parseHwp(buffer, options) {
22747
22961
  async function parsePdf(buffer, options) {
22748
22962
  let parsePdfDocument;
22749
22963
  try {
22750
- const mod = await import("./parser-4L7UFVEP.js");
22964
+ const mod = await import("./parser-HC5NXB3F.js");
22751
22965
  parsePdfDocument = mod.parsePdfDocument;
22752
22966
  } catch {
22753
22967
  return {
@@ -22872,4 +23086,4 @@ export {
22872
23086
  parseHwpml,
22873
23087
  fillForm
22874
23088
  };
22875
- //# sourceMappingURL=chunk-VMUP5WPI.js.map
23089
+ //# sourceMappingURL=chunk-LPKAF45D.js.map