kordoc 3.1.1 → 3.2.0
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/README.md +584 -559
- package/dist/{-UCE73NNK.js → -MSRLLJNM.js} +4 -4
- package/dist/{chunk-ZZNSI4GV.js → chunk-7KFBGOXZ.js} +2 -2
- package/dist/chunk-7KFBGOXZ.js.map +1 -0
- package/dist/{chunk-VMUP5WPI.js → chunk-CYLOXVYY.js} +247 -43
- package/dist/chunk-CYLOXVYY.js.map +1 -0
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-5CJGKKMZ.js → chunk-MEPHGCPQ.js} +1 -1
- package/dist/chunk-MEPHGCPQ.js.map +1 -0
- package/dist/chunk-MOL7MDBG.js +0 -0
- package/dist/{chunk-FJON4QNB.cjs → chunk-SWEBVX5K.cjs} +2 -2
- package/dist/chunk-SWEBVX5K.cjs.map +1 -0
- package/dist/{chunk-KR6DSGM7.js → chunk-ZWVTR2HQ.js} +2 -2
- package/dist/chunk-ZWVTR2HQ.js.map +1 -0
- package/dist/cli.js +72 -5
- package/dist/cli.js.map +1 -1
- package/dist/{detect-PJZMUL2Z.js → detect-RI2MQ33K.js} +2 -2
- package/dist/formula-5NKVS2LR.cjs.map +1 -1
- package/dist/formula-JCNF43NE.js +0 -0
- package/dist/index.cjs +409 -205
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +245 -41
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +5 -5
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-737B4EZW.js +0 -0
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-QTJL6IQY.js → parser-HAWIRFS4.js} +3 -3
- package/dist/parser-HAWIRFS4.js.map +1 -0
- package/dist/{parser-XULVNDMN.cjs → parser-LKIUKZJV.cjs} +15 -15
- package/dist/parser-LKIUKZJV.cjs.map +1 -0
- package/dist/{parser-4L7UFVEP.js → parser-U6KRTEB7.js} +3 -3
- package/dist/parser-U6KRTEB7.js.map +1 -0
- package/dist/{provider-H4WWSPOV.js → provider-4ZJKV3DC.js} +1 -1
- package/dist/provider-4ZJKV3DC.js.map +1 -0
- package/dist/{provider-7H4CPZYS.js → provider-AKROB7WQ.js} +1 -1
- package/dist/provider-AKROB7WQ.js.map +1 -0
- package/dist/{provider-5K7O3Z2O.cjs → provider-G4C2V2PD.cjs} +1 -1
- package/dist/provider-G4C2V2PD.cjs.map +1 -0
- package/dist/setup-57FB3LSP.js +0 -0
- package/dist/{watch-FPDSHB23.js → watch-OKZAU3I5.js} +4 -4
- package/dist/watch-OKZAU3I5.js.map +1 -0
- package/package.json +98 -98
- package/dist/chunk-5CJGKKMZ.js.map +0 -1
- package/dist/chunk-FJON4QNB.cjs.map +0 -1
- package/dist/chunk-KR6DSGM7.js.map +0 -1
- package/dist/chunk-VMUP5WPI.js.map +0 -1
- package/dist/chunk-ZZNSI4GV.js.map +0 -1
- package/dist/parser-4L7UFVEP.js.map +0 -1
- package/dist/parser-QTJL6IQY.js.map +0 -1
- package/dist/parser-XULVNDMN.cjs.map +0 -1
- package/dist/provider-5K7O3Z2O.cjs.map +0 -1
- package/dist/provider-7H4CPZYS.js.map +0 -1
- package/dist/provider-H4WWSPOV.js.map +0 -1
- package/dist/watch-FPDSHB23.js.map +0 -1
- /package/dist/{-UCE73NNK.js.map → -MSRLLJNM.js.map} +0 -0
- /package/dist/{detect-PJZMUL2Z.js.map → detect-RI2MQ33K.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -422,6 +422,42 @@ interface HwpxFillResult {
|
|
|
422
422
|
*/
|
|
423
423
|
declare function fillHwpx(hwpxBuffer: ArrayBuffer, values: Record<string, string>): Promise<HwpxFillResult>;
|
|
424
424
|
|
|
425
|
+
/**
|
|
426
|
+
* 공문서(公文書) 모드 — 한국 행정 공문서 표준 서식 렌더링 로직
|
|
427
|
+
*
|
|
428
|
+
* 근거: 「행정업무의 운영 및 혁신에 관한 규정」 및 동 시행규칙(제2조 항목 표시),
|
|
429
|
+
* 행정안전부 「2020 행정업무운영 편람」.
|
|
430
|
+
* 자세한 표준은 docs/gongmunseo-reference.md, 구현 매핑은 docs/gongmunseo-engine-spec.md 참조.
|
|
431
|
+
*
|
|
432
|
+
* 이 모듈은 **순수 로직**만 담는다(항목부호 시퀀스 생성, 단계별 들여쓰기 계산,
|
|
433
|
+
* 프리셋 해석). 실제 XML 조립은 generator.ts가 한다.
|
|
434
|
+
*/
|
|
435
|
+
type GongmunPreset = "official" | "report" | "plan" | "notice" | "minutes";
|
|
436
|
+
type GongmunNumbering = "standard" | "report";
|
|
437
|
+
type GongmunFont = "myeongjo" | "gothic";
|
|
438
|
+
/** 공문서 모드 옵션 (전부 선택 — 프리셋 기본값을 개별 override) */
|
|
439
|
+
interface GongmunOptions {
|
|
440
|
+
/** 문서 종류 프리셋. 기본 'official'(일반 기안문) */
|
|
441
|
+
preset?: GongmunPreset;
|
|
442
|
+
/** 본문 글꼴. 'myeongjo'=함초롬바탕(명조, 보고서·대외공문 관행) / 'gothic'=맑은 고딕(전자결재 기본) */
|
|
443
|
+
bodyFont?: GongmunFont;
|
|
444
|
+
/** 본문 글자 크기(pt). 기본 15 */
|
|
445
|
+
bodyPt?: number;
|
|
446
|
+
/** 본문 줄간격(%). 기본 160 (회의록 130) */
|
|
447
|
+
lineSpacing?: number;
|
|
448
|
+
/** 항목부호 체계. 'standard'=법정 8단계(1. 가. 1) …) / 'report'=보고서 불릿(□ ○ - ㆍ) */
|
|
449
|
+
numbering?: GongmunNumbering;
|
|
450
|
+
/** 용지 여백(mm). 기본 공식값 위20/아래10/좌20/우20 */
|
|
451
|
+
margins?: {
|
|
452
|
+
top: number;
|
|
453
|
+
bottom: number;
|
|
454
|
+
left: number;
|
|
455
|
+
right: number;
|
|
456
|
+
};
|
|
457
|
+
/** 문서 제목(첫 h1)을 가운데 정렬. 기본 true (행정기관명·보고서 제목) */
|
|
458
|
+
centerTitle?: boolean;
|
|
459
|
+
}
|
|
460
|
+
|
|
425
461
|
/**
|
|
426
462
|
* Markdown → HWPX 역변환
|
|
427
463
|
*
|
|
@@ -429,6 +465,7 @@ declare function fillHwpx(hwpxBuffer: ArrayBuffer, values: Record<string, string
|
|
|
429
465
|
* 순서/비순서 리스트, 수평선, 인용문, 테이블
|
|
430
466
|
* jszip으로 HWPX ZIP 패키징.
|
|
431
467
|
*/
|
|
468
|
+
|
|
432
469
|
/** HWPX 생성 시 적용할 시각 테마 (모두 선택) */
|
|
433
470
|
interface HwpxTheme {
|
|
434
471
|
/**
|
|
@@ -454,6 +491,12 @@ interface HwpxTheme {
|
|
|
454
491
|
/** markdownToHwpx 옵션 */
|
|
455
492
|
interface MarkdownToHwpxOptions {
|
|
456
493
|
theme?: HwpxTheme;
|
|
494
|
+
/**
|
|
495
|
+
* 공문서 모드 — 지정 시 한국 행정 공문서 표준 서식으로 렌더링한다.
|
|
496
|
+
* (공식 여백, 명조 15pt 본문, 항목부호 8단계 행갈굼 정렬, 줄간격 등)
|
|
497
|
+
* 미지정 시 기존 범용 마크다운 변환 동작 그대로 유지.
|
|
498
|
+
*/
|
|
499
|
+
gongmun?: GongmunOptions;
|
|
457
500
|
}
|
|
458
501
|
/**
|
|
459
502
|
* 마크다운 텍스트를 HWPX (ArrayBuffer)로 변환.
|
|
@@ -861,4 +904,4 @@ interface FillFormOutput {
|
|
|
861
904
|
*/
|
|
862
905
|
declare function fillForm(input: string | ArrayBuffer | Buffer, values: Record<string, string>, outputFormat?: FillOutputFormat): Promise<FillFormOutput>;
|
|
863
906
|
|
|
864
|
-
export { type BlockCapability, type BlockCapabilityInfo, type BlockDiff, type BlockEdit, type BlockSourceRef, type BoundingBox, type CellCapability, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormFieldSchema, type FormFieldType, type FormResult, type FormSchemaResult, type HwpxFillResult, HwpxSession, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type OcrProvider, type OutlineItem, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PatchOptions, type PatchResult, type PatchSkip, type PrintOptions, type PrintPreset, type ScanCell, type ScanParaKind, type ScanParagraph, type ScanTable, type SectionScan, type SpliceEdit, type TRange, VERSION, type WarningCode, type WatchOptions, applySplices, blocksToMarkdown, blocksToPdf, buildParagraphSplices, buildRangeSplices, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, extractFormSchema, fillForm, fillFormFields, fillHwpx, inferFieldType, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, openHwpxDocument, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, patchHwp, patchHwpx, patchHwpxBlocks, renderHtml, scanSectionXml };
|
|
907
|
+
export { type BlockCapability, type BlockCapabilityInfo, type BlockDiff, type BlockEdit, type BlockSourceRef, type BoundingBox, type CellCapability, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormFieldSchema, type FormFieldType, type FormResult, type FormSchemaResult, type GongmunFont, type GongmunNumbering, type GongmunOptions, type GongmunPreset, type HwpxFillResult, HwpxSession, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type OcrProvider, type OutlineItem, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PatchOptions, type PatchResult, type PatchSkip, type PrintOptions, type PrintPreset, type ScanCell, type ScanParaKind, type ScanParagraph, type ScanTable, type SectionScan, type SpliceEdit, type TRange, VERSION, type WarningCode, type WatchOptions, applySplices, blocksToMarkdown, blocksToPdf, buildParagraphSplices, buildRangeSplices, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, extractFormSchema, fillForm, fillFormFields, fillHwpx, inferFieldType, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, openHwpxDocument, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, patchHwp, patchHwpx, patchHwpxBlocks, renderHtml, scanSectionXml };
|
package/dist/index.d.ts
CHANGED
|
@@ -422,6 +422,42 @@ interface HwpxFillResult {
|
|
|
422
422
|
*/
|
|
423
423
|
declare function fillHwpx(hwpxBuffer: ArrayBuffer, values: Record<string, string>): Promise<HwpxFillResult>;
|
|
424
424
|
|
|
425
|
+
/**
|
|
426
|
+
* 공문서(公文書) 모드 — 한국 행정 공문서 표준 서식 렌더링 로직
|
|
427
|
+
*
|
|
428
|
+
* 근거: 「행정업무의 운영 및 혁신에 관한 규정」 및 동 시행규칙(제2조 항목 표시),
|
|
429
|
+
* 행정안전부 「2020 행정업무운영 편람」.
|
|
430
|
+
* 자세한 표준은 docs/gongmunseo-reference.md, 구현 매핑은 docs/gongmunseo-engine-spec.md 참조.
|
|
431
|
+
*
|
|
432
|
+
* 이 모듈은 **순수 로직**만 담는다(항목부호 시퀀스 생성, 단계별 들여쓰기 계산,
|
|
433
|
+
* 프리셋 해석). 실제 XML 조립은 generator.ts가 한다.
|
|
434
|
+
*/
|
|
435
|
+
type GongmunPreset = "official" | "report" | "plan" | "notice" | "minutes";
|
|
436
|
+
type GongmunNumbering = "standard" | "report";
|
|
437
|
+
type GongmunFont = "myeongjo" | "gothic";
|
|
438
|
+
/** 공문서 모드 옵션 (전부 선택 — 프리셋 기본값을 개별 override) */
|
|
439
|
+
interface GongmunOptions {
|
|
440
|
+
/** 문서 종류 프리셋. 기본 'official'(일반 기안문) */
|
|
441
|
+
preset?: GongmunPreset;
|
|
442
|
+
/** 본문 글꼴. 'myeongjo'=함초롬바탕(명조, 보고서·대외공문 관행) / 'gothic'=맑은 고딕(전자결재 기본) */
|
|
443
|
+
bodyFont?: GongmunFont;
|
|
444
|
+
/** 본문 글자 크기(pt). 기본 15 */
|
|
445
|
+
bodyPt?: number;
|
|
446
|
+
/** 본문 줄간격(%). 기본 160 (회의록 130) */
|
|
447
|
+
lineSpacing?: number;
|
|
448
|
+
/** 항목부호 체계. 'standard'=법정 8단계(1. 가. 1) …) / 'report'=보고서 불릿(□ ○ - ㆍ) */
|
|
449
|
+
numbering?: GongmunNumbering;
|
|
450
|
+
/** 용지 여백(mm). 기본 공식값 위20/아래10/좌20/우20 */
|
|
451
|
+
margins?: {
|
|
452
|
+
top: number;
|
|
453
|
+
bottom: number;
|
|
454
|
+
left: number;
|
|
455
|
+
right: number;
|
|
456
|
+
};
|
|
457
|
+
/** 문서 제목(첫 h1)을 가운데 정렬. 기본 true (행정기관명·보고서 제목) */
|
|
458
|
+
centerTitle?: boolean;
|
|
459
|
+
}
|
|
460
|
+
|
|
425
461
|
/**
|
|
426
462
|
* Markdown → HWPX 역변환
|
|
427
463
|
*
|
|
@@ -429,6 +465,7 @@ declare function fillHwpx(hwpxBuffer: ArrayBuffer, values: Record<string, string
|
|
|
429
465
|
* 순서/비순서 리스트, 수평선, 인용문, 테이블
|
|
430
466
|
* jszip으로 HWPX ZIP 패키징.
|
|
431
467
|
*/
|
|
468
|
+
|
|
432
469
|
/** HWPX 생성 시 적용할 시각 테마 (모두 선택) */
|
|
433
470
|
interface HwpxTheme {
|
|
434
471
|
/**
|
|
@@ -454,6 +491,12 @@ interface HwpxTheme {
|
|
|
454
491
|
/** markdownToHwpx 옵션 */
|
|
455
492
|
interface MarkdownToHwpxOptions {
|
|
456
493
|
theme?: HwpxTheme;
|
|
494
|
+
/**
|
|
495
|
+
* 공문서 모드 — 지정 시 한국 행정 공문서 표준 서식으로 렌더링한다.
|
|
496
|
+
* (공식 여백, 명조 15pt 본문, 항목부호 8단계 행갈굼 정렬, 줄간격 등)
|
|
497
|
+
* 미지정 시 기존 범용 마크다운 변환 동작 그대로 유지.
|
|
498
|
+
*/
|
|
499
|
+
gongmun?: GongmunOptions;
|
|
457
500
|
}
|
|
458
501
|
/**
|
|
459
502
|
* 마크다운 텍스트를 HWPX (ArrayBuffer)로 변환.
|
|
@@ -861,4 +904,4 @@ interface FillFormOutput {
|
|
|
861
904
|
*/
|
|
862
905
|
declare function fillForm(input: string | ArrayBuffer | Buffer, values: Record<string, string>, outputFormat?: FillOutputFormat): Promise<FillFormOutput>;
|
|
863
906
|
|
|
864
|
-
export { type BlockCapability, type BlockCapabilityInfo, type BlockDiff, type BlockEdit, type BlockSourceRef, type BoundingBox, type CellCapability, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormFieldSchema, type FormFieldType, type FormResult, type FormSchemaResult, type HwpxFillResult, HwpxSession, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type OcrProvider, type OutlineItem, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PatchOptions, type PatchResult, type PatchSkip, type PrintOptions, type PrintPreset, type ScanCell, type ScanParaKind, type ScanParagraph, type ScanTable, type SectionScan, type SpliceEdit, type TRange, VERSION, type WarningCode, type WatchOptions, applySplices, blocksToMarkdown, blocksToPdf, buildParagraphSplices, buildRangeSplices, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, extractFormSchema, fillForm, fillFormFields, fillHwpx, inferFieldType, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, openHwpxDocument, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, patchHwp, patchHwpx, patchHwpxBlocks, renderHtml, scanSectionXml };
|
|
907
|
+
export { type BlockCapability, type BlockCapabilityInfo, type BlockDiff, type BlockEdit, type BlockSourceRef, type BoundingBox, type CellCapability, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormFieldSchema, type FormFieldType, type FormResult, type FormSchemaResult, type GongmunFont, type GongmunNumbering, type GongmunOptions, type GongmunPreset, type HwpxFillResult, HwpxSession, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type OcrProvider, type OutlineItem, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PatchOptions, type PatchResult, type PatchSkip, type PrintOptions, type PrintPreset, type ScanCell, type ScanParaKind, type ScanParagraph, type ScanTable, type SectionScan, type SpliceEdit, type TRange, VERSION, type WarningCode, type WatchOptions, applySplices, blocksToMarkdown, blocksToPdf, buildParagraphSplices, buildRangeSplices, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, extractFormSchema, fillForm, fillFormFields, fillHwpx, inferFieldType, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, openHwpxDocument, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, patchHwp, patchHwpx, patchHwpxBlocks, renderHtml, scanSectionXml };
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
sanitizeHref,
|
|
18
18
|
stripDtd,
|
|
19
19
|
toArrayBuffer
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-7KFBGOXZ.js";
|
|
21
21
|
import {
|
|
22
22
|
parsePageRange
|
|
23
23
|
} from "./chunk-GE43BE46.js";
|
|
@@ -19978,9 +19978,115 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
19978
19978
|
|
|
19979
19979
|
// src/hwpx/generator.ts
|
|
19980
19980
|
import JSZip6 from "jszip";
|
|
19981
|
+
|
|
19982
|
+
// src/hwpx/gongmun.ts
|
|
19983
|
+
var OFFICIAL_MARGINS = { top: 20, bottom: 10, left: 20, right: 20 };
|
|
19984
|
+
var PRESET_DEFAULTS = {
|
|
19985
|
+
official: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
|
|
19986
|
+
report: { bodyPt: 15, lineSpacing: 160, numbering: "report" },
|
|
19987
|
+
plan: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
|
|
19988
|
+
notice: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
|
|
19989
|
+
minutes: { bodyPt: 14, lineSpacing: 130, numbering: "standard" }
|
|
19990
|
+
};
|
|
19991
|
+
function resolveGongmun(opts) {
|
|
19992
|
+
const preset = opts.preset ?? "official";
|
|
19993
|
+
const d = PRESET_DEFAULTS[preset];
|
|
19994
|
+
const bodyPt = opts.bodyPt ?? d.bodyPt;
|
|
19995
|
+
return {
|
|
19996
|
+
preset,
|
|
19997
|
+
bodyFont: opts.bodyFont ?? "myeongjo",
|
|
19998
|
+
bodyHeight: Math.round(bodyPt * 100),
|
|
19999
|
+
lineSpacing: opts.lineSpacing ?? d.lineSpacing,
|
|
20000
|
+
numbering: opts.numbering ?? d.numbering,
|
|
20001
|
+
margins: opts.margins ?? OFFICIAL_MARGINS,
|
|
20002
|
+
centerTitle: opts.centerTitle ?? true
|
|
20003
|
+
};
|
|
20004
|
+
}
|
|
20005
|
+
var HANGUL_INITIALS = [0, 2, 3, 5, 6, 7, 9, 11, 12, 14, 15, 16, 17, 18];
|
|
20006
|
+
var HANGUL_MEDIALS = [0, 4, 8, 13, 18, 20];
|
|
20007
|
+
function hangulOrdinal(n) {
|
|
20008
|
+
const cols = HANGUL_INITIALS.length;
|
|
20009
|
+
const vowel = HANGUL_MEDIALS[Math.min(Math.floor(n / cols), HANGUL_MEDIALS.length - 1)];
|
|
20010
|
+
const init = HANGUL_INITIALS[n % cols];
|
|
20011
|
+
return String.fromCodePoint(44032 + init * 588 + vowel * 28);
|
|
20012
|
+
}
|
|
20013
|
+
function circledNumber(n) {
|
|
20014
|
+
return String.fromCodePoint(9312 + n % 20);
|
|
20015
|
+
}
|
|
20016
|
+
function circledHangul(n) {
|
|
20017
|
+
return String.fromCodePoint(12910 + n % 14);
|
|
20018
|
+
}
|
|
20019
|
+
var REPORT_BULLETS = ["\u25A1", "\u25CB", "-", "\u318D"];
|
|
20020
|
+
function standardMarker(depth, n) {
|
|
20021
|
+
switch (depth) {
|
|
20022
|
+
case 0:
|
|
20023
|
+
return `${n + 1}.`;
|
|
20024
|
+
case 1:
|
|
20025
|
+
return `${hangulOrdinal(n)}.`;
|
|
20026
|
+
case 2:
|
|
20027
|
+
return `${n + 1})`;
|
|
20028
|
+
case 3:
|
|
20029
|
+
return `${hangulOrdinal(n)})`;
|
|
20030
|
+
case 4:
|
|
20031
|
+
return `(${n + 1})`;
|
|
20032
|
+
case 5:
|
|
20033
|
+
return `(${hangulOrdinal(n)})`;
|
|
20034
|
+
case 6:
|
|
20035
|
+
return circledNumber(n);
|
|
20036
|
+
case 7:
|
|
20037
|
+
return circledHangul(n);
|
|
20038
|
+
default:
|
|
20039
|
+
return circledHangul(n);
|
|
20040
|
+
}
|
|
20041
|
+
}
|
|
20042
|
+
function reportMarker(depth) {
|
|
20043
|
+
return REPORT_BULLETS[Math.min(depth, REPORT_BULLETS.length - 1)];
|
|
20044
|
+
}
|
|
20045
|
+
function levelIndent(depth, bodyHeight, numbering) {
|
|
20046
|
+
const ta = bodyHeight / 2;
|
|
20047
|
+
const markerTa = numbering === "standard" && (depth === 4 || depth === 5) ? 3 : 2;
|
|
20048
|
+
const hang = Math.round((markerTa + 1) * ta);
|
|
20049
|
+
return { left: Math.round(depth * bodyHeight), indent: -hang };
|
|
20050
|
+
}
|
|
20051
|
+
function computeSuppression(depths) {
|
|
20052
|
+
const counts = /* @__PURE__ */ new Map();
|
|
20053
|
+
const keys = [];
|
|
20054
|
+
const path = [];
|
|
20055
|
+
for (const depth of depths) {
|
|
20056
|
+
path.length = depth + 1;
|
|
20057
|
+
path[depth] = (path[depth] ?? 0) + 1;
|
|
20058
|
+
const parentKey = path.slice(0, depth).join(".") + "|" + depth;
|
|
20059
|
+
keys.push(parentKey);
|
|
20060
|
+
counts.set(parentKey, (counts.get(parentKey) ?? 0) + 1);
|
|
20061
|
+
}
|
|
20062
|
+
return keys.map((k) => (counts.get(k) ?? 0) <= 1);
|
|
20063
|
+
}
|
|
20064
|
+
var GongmunNumberer = class {
|
|
20065
|
+
constructor(numbering) {
|
|
20066
|
+
this.numbering = numbering;
|
|
20067
|
+
}
|
|
20068
|
+
counts = [];
|
|
20069
|
+
/** depth 항목 하나에 대한 마커. suppress=true면 빈 문자열(부호 없음) */
|
|
20070
|
+
next(depth, suppress) {
|
|
20071
|
+
this.counts.length = depth + 1;
|
|
20072
|
+
const n = this.counts[depth] ?? 0;
|
|
20073
|
+
this.counts[depth] = n + 1;
|
|
20074
|
+
if (suppress) return "";
|
|
20075
|
+
return this.numbering === "report" ? reportMarker(depth) : standardMarker(depth, n);
|
|
20076
|
+
}
|
|
20077
|
+
reset() {
|
|
20078
|
+
this.counts = [];
|
|
20079
|
+
}
|
|
20080
|
+
};
|
|
20081
|
+
function mmToHwpunit(mm) {
|
|
20082
|
+
return Math.round(mm * 7200 / 25.4);
|
|
20083
|
+
}
|
|
20084
|
+
|
|
20085
|
+
// src/hwpx/generator.ts
|
|
19981
20086
|
var NS_SECTION = "http://www.hancom.co.kr/hwpml/2011/section";
|
|
19982
20087
|
var NS_PARA = "http://www.hancom.co.kr/hwpml/2011/paragraph";
|
|
19983
20088
|
var NS_HEAD = "http://www.hancom.co.kr/hwpml/2011/head";
|
|
20089
|
+
var NS_CORE = "http://www.hancom.co.kr/hwpml/2011/core";
|
|
19984
20090
|
var NS_OPF = "http://www.idpf.org/2007/opf/";
|
|
19985
20091
|
var NS_HPF = "http://www.hancom.co.kr/schema/2011/hpf";
|
|
19986
20092
|
var NS_OCF = "urn:oasis:names:tc:opendocument:xmlns:container";
|
|
@@ -20020,13 +20126,14 @@ function resolveTheme(theme) {
|
|
|
20020
20126
|
}
|
|
20021
20127
|
async function markdownToHwpx(markdown, options) {
|
|
20022
20128
|
const theme = resolveTheme(options?.theme);
|
|
20129
|
+
const gongmun = options?.gongmun ? resolveGongmun(options.gongmun) : null;
|
|
20023
20130
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
20024
|
-
const sectionXml = blocksToSectionXml(blocks, theme);
|
|
20131
|
+
const sectionXml = blocksToSectionXml(blocks, theme, gongmun);
|
|
20025
20132
|
const zip = new JSZip6();
|
|
20026
20133
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
20027
20134
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
20028
20135
|
zip.file("Contents/content.hpf", generateManifest());
|
|
20029
|
-
zip.file("Contents/header.xml", generateHeaderXml(theme));
|
|
20136
|
+
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun));
|
|
20030
20137
|
zip.file("Contents/section0.xml", sectionXml);
|
|
20031
20138
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
20032
20139
|
return await zip.generateAsync({ type: "arraybuffer" });
|
|
@@ -20219,25 +20326,95 @@ function charPr(id, height, bold, italic, fontId = 0, textColor = DEFAULT_TEXT_C
|
|
|
20219
20326
|
</hh:charPr>`;
|
|
20220
20327
|
}
|
|
20221
20328
|
function paraPr(id, opts = {}) {
|
|
20222
|
-
const { align = "JUSTIFY", spaceBefore = 0, spaceAfter = 0, lineSpacing = 160, indent = 0 } = opts;
|
|
20329
|
+
const { align = "JUSTIFY", spaceBefore = 0, spaceAfter = 0, lineSpacing = 160, indent = 0, left = 0 } = opts;
|
|
20223
20330
|
return ` <hh:paraPr id="${id}" tabPrIDRef="0" condense="0" fontLineHeight="0" snapToGrid="1" suppressLineNumbers="0" checked="0" textDir="AUTO">
|
|
20224
20331
|
<hh:align horizontal="${align}" vertical="BASELINE"/>
|
|
20225
20332
|
<hh:heading type="NONE" idRef="0" level="0"/>
|
|
20226
20333
|
<hh:breakSetting breakLatinWord="KEEP_WORD" breakNonLatinWord="BREAK_WORD" widowOrphan="0" keepWithNext="0" keepLines="0" pageBreakBefore="0" lineWrap="BREAK"/>
|
|
20227
20334
|
<hh:autoSpacing eAsianEng="0" eAsianNum="0"/>
|
|
20228
|
-
<hh:margin
|
|
20335
|
+
<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>
|
|
20229
20336
|
<hh:lineSpacing type="PERCENT" value="${lineSpacing}"/>
|
|
20230
20337
|
<hh:border borderFillIDRef="0" offsetLeft="0" offsetRight="0" offsetTop="0" offsetBottom="0" connect="0" ignoreMargin="0"/>
|
|
20231
20338
|
</hh:paraPr>`;
|
|
20232
20339
|
}
|
|
20233
|
-
|
|
20340
|
+
var GONGMUN_LIST_BASE = 8;
|
|
20341
|
+
var GONGMUN_LIST_LEVELS = 8;
|
|
20342
|
+
var GONGMUN_CENTER = GONGMUN_LIST_BASE + GONGMUN_LIST_LEVELS;
|
|
20343
|
+
function buildCharProperties(theme, gongmun) {
|
|
20344
|
+
let body = 1e3, code = 900, h1 = 1800, h2 = 1400, h3 = 1200, h4 = 1100;
|
|
20345
|
+
if (gongmun) {
|
|
20346
|
+
body = gongmun.bodyHeight;
|
|
20347
|
+
code = Math.max(body - 200, 900);
|
|
20348
|
+
h1 = gongmun.preset === "report" || gongmun.preset === "plan" ? 2e3 : 1700;
|
|
20349
|
+
h2 = 1600;
|
|
20350
|
+
h3 = body;
|
|
20351
|
+
h4 = Math.max(body - 100, 1300);
|
|
20352
|
+
}
|
|
20353
|
+
const rows = [
|
|
20354
|
+
charPr(0, body, false, false, 0, theme.body),
|
|
20355
|
+
charPr(1, body, true, false, 0, theme.body),
|
|
20356
|
+
charPr(2, body, false, true, 0, theme.body),
|
|
20357
|
+
charPr(3, body, true, true, 0, theme.body),
|
|
20358
|
+
charPr(4, code, false, false, 1),
|
|
20359
|
+
charPr(5, h1, true, false, 1, theme.h1),
|
|
20360
|
+
charPr(6, h2, true, false, 1, theme.h2),
|
|
20361
|
+
charPr(7, h3, true, false, 1, theme.h3),
|
|
20362
|
+
charPr(8, h4, true, false, 1, theme.h4),
|
|
20363
|
+
charPr(CHAR_TABLE_HEADER, body, theme.tableHeaderBold, false, 0, theme.tableHeader),
|
|
20364
|
+
charPr(CHAR_QUOTE, body, false, true, 0, theme.quote)
|
|
20365
|
+
];
|
|
20366
|
+
return `<hh:charProperties itemCnt="${rows.length}">
|
|
20367
|
+
${rows.join("\n")}
|
|
20368
|
+
</hh:charProperties>`;
|
|
20369
|
+
}
|
|
20370
|
+
function buildParaProperties(gongmun) {
|
|
20371
|
+
if (!gongmun) {
|
|
20372
|
+
const base2 = [
|
|
20373
|
+
paraPr(0),
|
|
20374
|
+
paraPr(1, { align: "LEFT", spaceBefore: 800, spaceAfter: 200, lineSpacing: 180 }),
|
|
20375
|
+
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: 170 }),
|
|
20376
|
+
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: 160 }),
|
|
20377
|
+
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: 160 }),
|
|
20378
|
+
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 }),
|
|
20379
|
+
paraPr(6, { align: "LEFT", lineSpacing: 150, indent: 600 }),
|
|
20380
|
+
paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })
|
|
20381
|
+
];
|
|
20382
|
+
return `<hh:paraProperties itemCnt="${base2.length}">
|
|
20383
|
+
${base2.join("\n")}
|
|
20384
|
+
</hh:paraProperties>`;
|
|
20385
|
+
}
|
|
20386
|
+
const ls = gongmun.lineSpacing;
|
|
20387
|
+
const titleAlign = gongmun.centerTitle ? "CENTER" : "LEFT";
|
|
20388
|
+
const base = [
|
|
20389
|
+
paraPr(0, { lineSpacing: ls }),
|
|
20390
|
+
paraPr(1, { align: titleAlign, spaceBefore: 400, spaceAfter: 400, lineSpacing: ls }),
|
|
20391
|
+
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: ls }),
|
|
20392
|
+
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: ls }),
|
|
20393
|
+
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: ls }),
|
|
20394
|
+
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 }),
|
|
20395
|
+
paraPr(6, { align: "LEFT", lineSpacing: ls, indent: 600 }),
|
|
20396
|
+
paraPr(7, { align: "LEFT", lineSpacing: ls, indent: 600 })
|
|
20397
|
+
];
|
|
20398
|
+
for (let d = 0; d < GONGMUN_LIST_LEVELS; d++) {
|
|
20399
|
+
const { left, indent } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering);
|
|
20400
|
+
base.push(paraPr(GONGMUN_LIST_BASE + d, { align: "JUSTIFY", lineSpacing: ls, left, indent }));
|
|
20401
|
+
}
|
|
20402
|
+
base.push(paraPr(GONGMUN_CENTER, { align: "CENTER", lineSpacing: ls }));
|
|
20403
|
+
return `<hh:paraProperties itemCnt="${base.length}">
|
|
20404
|
+
${base.join("\n")}
|
|
20405
|
+
</hh:paraProperties>`;
|
|
20406
|
+
}
|
|
20407
|
+
function generateHeaderXml(theme, gongmun) {
|
|
20408
|
+
const bodyFace = gongmun?.bodyFont === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
|
|
20409
|
+
const charPropsXml = buildCharProperties(theme, gongmun);
|
|
20410
|
+
const paraPropsXml = buildParaProperties(gongmun);
|
|
20234
20411
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
20235
|
-
<hh:head xmlns:hh="${NS_HEAD}" xmlns:hp="${NS_PARA}" version="1.4" secCnt="1">
|
|
20412
|
+
<hh:head xmlns:hh="${NS_HEAD}" xmlns:hp="${NS_PARA}" xmlns:hc="${NS_CORE}" version="1.4" secCnt="1">
|
|
20236
20413
|
<hh:beginNum page="1" footnote="1" endnote="1" pic="1" tbl="1" equation="1"/>
|
|
20237
20414
|
<hh:refList>
|
|
20238
20415
|
<hh:fontfaces itemCnt="7">
|
|
20239
20416
|
<hh:fontface lang="HANGUL" fontCnt="3">
|
|
20240
|
-
<hh:font id="0" face="
|
|
20417
|
+
<hh:font id="0" face="${bodyFace}" type="TTF" isEmbedded="0">
|
|
20241
20418
|
<hh:typeInfo familyType="FCAT_GOTHIC" weight="6" proportion="4" contrast="0" strokeVariation="1" armStyle="1" letterform="1" midline="1" xHeight="1"/>
|
|
20242
20419
|
</hh:font>
|
|
20243
20420
|
<hh:font id="1" face="\uD568\uCD08\uB86C\uB3CB\uC6C0" type="TTF" isEmbedded="0">
|
|
@@ -20306,32 +20483,11 @@ function generateHeaderXml(theme) {
|
|
|
20306
20483
|
<hh:fillInfo/>
|
|
20307
20484
|
</hh:borderFill>
|
|
20308
20485
|
</hh:borderFills>
|
|
20309
|
-
|
|
20310
|
-
${charPr(0, 1e3, false, false, 0, theme.body)}
|
|
20311
|
-
${charPr(1, 1e3, true, false, 0, theme.body)}
|
|
20312
|
-
${charPr(2, 1e3, false, true, 0, theme.body)}
|
|
20313
|
-
${charPr(3, 1e3, true, true, 0, theme.body)}
|
|
20314
|
-
${charPr(4, 900, false, false, 1)}
|
|
20315
|
-
${charPr(5, 1800, true, false, 1, theme.h1)}
|
|
20316
|
-
${charPr(6, 1400, true, false, 1, theme.h2)}
|
|
20317
|
-
${charPr(7, 1200, true, false, 1, theme.h3)}
|
|
20318
|
-
${charPr(8, 1100, true, false, 1, theme.h4)}
|
|
20319
|
-
${charPr(CHAR_TABLE_HEADER, 1e3, theme.tableHeaderBold, false, 0, theme.tableHeader)}
|
|
20320
|
-
${charPr(CHAR_QUOTE, 1e3, false, true, 0, theme.quote)}
|
|
20321
|
-
</hh:charProperties>
|
|
20486
|
+
${charPropsXml}
|
|
20322
20487
|
<hh:tabProperties itemCnt="0"/>
|
|
20323
20488
|
<hh:numberings itemCnt="0"/>
|
|
20324
20489
|
<hh:bullets itemCnt="0"/>
|
|
20325
|
-
|
|
20326
|
-
${paraPr(0)}
|
|
20327
|
-
${paraPr(1, { align: "LEFT", spaceBefore: 800, spaceAfter: 200, lineSpacing: 180 })}
|
|
20328
|
-
${paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: 170 })}
|
|
20329
|
-
${paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: 160 })}
|
|
20330
|
-
${paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: 160 })}
|
|
20331
|
-
${paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 })}
|
|
20332
|
-
${paraPr(6, { align: "LEFT", lineSpacing: 150, indent: 600 })}
|
|
20333
|
-
${paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })}
|
|
20334
|
-
</hh:paraProperties>
|
|
20490
|
+
${paraPropsXml}
|
|
20335
20491
|
<hh:styles itemCnt="1">
|
|
20336
20492
|
<hh:style id="0" type="PARA" name="\uBC14\uD0D5\uAE00" engName="Normal" paraPrIDRef="0" charPrIDRef="0" nextStyleIDRef="0" langIDRef="1042" lockForm="0"/>
|
|
20337
20493
|
</hh:styles>
|
|
@@ -20339,8 +20495,16 @@ ${paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })}
|
|
|
20339
20495
|
<hh:compatibleDocument targetProgram="HWP2018"/>
|
|
20340
20496
|
</hh:head>`;
|
|
20341
20497
|
}
|
|
20342
|
-
function generateSecPr() {
|
|
20343
|
-
|
|
20498
|
+
function generateSecPr(gongmun) {
|
|
20499
|
+
const m = gongmun ? {
|
|
20500
|
+
top: mmToHwpunit(gongmun.margins.top),
|
|
20501
|
+
bottom: mmToHwpunit(gongmun.margins.bottom),
|
|
20502
|
+
left: mmToHwpunit(gongmun.margins.left),
|
|
20503
|
+
right: mmToHwpunit(gongmun.margins.right),
|
|
20504
|
+
header: 0,
|
|
20505
|
+
footer: 0
|
|
20506
|
+
} : { top: 8504, bottom: 4252, left: 5670, right: 4252, header: 2835, footer: 2835 };
|
|
20507
|
+
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>`;
|
|
20344
20508
|
}
|
|
20345
20509
|
var TABLE_ID_BASE = 1e3;
|
|
20346
20510
|
var tableIdCounter = TABLE_ID_BASE;
|
|
@@ -20371,12 +20535,37 @@ function generateTable(rows, theme) {
|
|
|
20371
20535
|
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>`;
|
|
20372
20536
|
return `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${tbl}</hp:run></hp:p>`;
|
|
20373
20537
|
}
|
|
20374
|
-
function
|
|
20538
|
+
function precomputeGongmunList(blocks, gongmun) {
|
|
20539
|
+
const result = /* @__PURE__ */ new Map();
|
|
20540
|
+
let i = 0;
|
|
20541
|
+
while (i < blocks.length) {
|
|
20542
|
+
if (blocks[i].type !== "list_item") {
|
|
20543
|
+
i++;
|
|
20544
|
+
continue;
|
|
20545
|
+
}
|
|
20546
|
+
const run = [];
|
|
20547
|
+
while (i < blocks.length && blocks[i].type === "list_item") {
|
|
20548
|
+
run.push(i);
|
|
20549
|
+
i++;
|
|
20550
|
+
}
|
|
20551
|
+
const depths = run.map((bi) => Math.min(Math.max(blocks[bi].indent || 0, 0), GONGMUN_LIST_LEVELS - 1));
|
|
20552
|
+
const suppress = gongmun.numbering === "standard" ? computeSuppression(depths) : depths.map(() => false);
|
|
20553
|
+
const numberer = new GongmunNumberer(gongmun.numbering);
|
|
20554
|
+
run.forEach((bi, k) => {
|
|
20555
|
+
const marker = numberer.next(depths[k], suppress[k]);
|
|
20556
|
+
result.set(bi, { marker, depth: depths[k] });
|
|
20557
|
+
});
|
|
20558
|
+
}
|
|
20559
|
+
return result;
|
|
20560
|
+
}
|
|
20561
|
+
function blocksToSectionXml(blocks, theme, gongmun) {
|
|
20375
20562
|
const paraXmls = [];
|
|
20376
20563
|
let isFirst = true;
|
|
20377
20564
|
const orderedCounters = {};
|
|
20378
20565
|
let prevWasOrdered = false;
|
|
20379
|
-
|
|
20566
|
+
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
20567
|
+
for (let blockIdx = 0; blockIdx < blocks.length; blockIdx++) {
|
|
20568
|
+
const block = blocks[blockIdx];
|
|
20380
20569
|
let xml = "";
|
|
20381
20570
|
if (block.type !== "list_item" || !block.ordered) {
|
|
20382
20571
|
if (prevWasOrdered) {
|
|
@@ -20391,9 +20580,15 @@ function blocksToSectionXml(blocks, theme) {
|
|
|
20391
20580
|
xml = generateParagraph(block.text || "", pId, cId);
|
|
20392
20581
|
break;
|
|
20393
20582
|
}
|
|
20394
|
-
case "paragraph":
|
|
20395
|
-
|
|
20583
|
+
case "paragraph": {
|
|
20584
|
+
const ctr = gongmun && /^<center>([\s\S]*)<\/center>$/i.exec((block.text || "").trim());
|
|
20585
|
+
if (ctr) {
|
|
20586
|
+
xml = generateParagraph(ctr[1].trim(), GONGMUN_CENTER);
|
|
20587
|
+
} else {
|
|
20588
|
+
xml = generateParagraph(block.text || "");
|
|
20589
|
+
}
|
|
20396
20590
|
break;
|
|
20591
|
+
}
|
|
20397
20592
|
case "code_block": {
|
|
20398
20593
|
const codeLines = (block.text || "").split("\n");
|
|
20399
20594
|
xml = codeLines.map((line) => generateParagraph(line || " ", PARA_CODE)).join("\n ");
|
|
@@ -20407,6 +20602,15 @@ function blocksToSectionXml(blocks, theme) {
|
|
|
20407
20602
|
);
|
|
20408
20603
|
break;
|
|
20409
20604
|
case "list_item": {
|
|
20605
|
+
if (gongmun && gongmunList) {
|
|
20606
|
+
const info = gongmunList.get(blockIdx);
|
|
20607
|
+
const depth = info?.depth ?? 0;
|
|
20608
|
+
const marker2 = info?.marker ?? "";
|
|
20609
|
+
const content = block.text || "";
|
|
20610
|
+
const text = marker2 ? `${marker2} ${content}` : content;
|
|
20611
|
+
xml = generateParagraph(text, GONGMUN_LIST_BASE + depth);
|
|
20612
|
+
break;
|
|
20613
|
+
}
|
|
20410
20614
|
const indent = block.indent || 0;
|
|
20411
20615
|
let marker;
|
|
20412
20616
|
if (block.ordered) {
|
|
@@ -20433,7 +20637,7 @@ function blocksToSectionXml(blocks, theme) {
|
|
|
20433
20637
|
case "table":
|
|
20434
20638
|
if (block.rows) {
|
|
20435
20639
|
if (isFirst) {
|
|
20436
|
-
const secRun = `<hp:run charPrIDRef="0">${generateSecPr()}<hp:t></hp:t></hp:run>`;
|
|
20640
|
+
const secRun = `<hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run>`;
|
|
20437
20641
|
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
|
|
20438
20642
|
isFirst = false;
|
|
20439
20643
|
}
|
|
@@ -20445,14 +20649,14 @@ function blocksToSectionXml(blocks, theme) {
|
|
|
20445
20649
|
if (isFirst && block.type !== "table") {
|
|
20446
20650
|
xml = xml.replace(
|
|
20447
20651
|
/<hp:run charPrIDRef="(\d+)">/,
|
|
20448
|
-
`<hp:run charPrIDRef="$1">${generateSecPr()}`
|
|
20652
|
+
`<hp:run charPrIDRef="$1">${generateSecPr(gongmun)}`
|
|
20449
20653
|
);
|
|
20450
20654
|
isFirst = false;
|
|
20451
20655
|
}
|
|
20452
20656
|
paraXmls.push(xml);
|
|
20453
20657
|
}
|
|
20454
20658
|
if (paraXmls.length === 0) {
|
|
20455
|
-
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${generateSecPr()}<hp:t></hp:t></hp:run></hp:p>`);
|
|
20659
|
+
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run></hp:p>`);
|
|
20456
20660
|
}
|
|
20457
20661
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
20458
20662
|
<hs:sec xmlns:hs="${NS_SECTION}" xmlns:hp="${NS_PARA}">
|
|
@@ -22965,7 +23169,7 @@ async function parseHwp(buffer, options) {
|
|
|
22965
23169
|
async function parsePdf(buffer, options) {
|
|
22966
23170
|
let parsePdfDocument;
|
|
22967
23171
|
try {
|
|
22968
|
-
const mod = await import("./parser-
|
|
23172
|
+
const mod = await import("./parser-HAWIRFS4.js");
|
|
22969
23173
|
parsePdfDocument = mod.parsePdfDocument;
|
|
22970
23174
|
} catch {
|
|
22971
23175
|
return {
|