hwpkit-dev 0.0.1 → 0.0.3
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/ .npmignore +4 -1
- package/README.md +39 -2
- package/dist/index.d.mts +74 -16
- package/dist/index.d.ts +70 -16
- package/dist/index.js +4985 -698
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4981 -698
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
- package/playground/index.html +346 -0
- package/playground/main.ts +302 -0
- package/playground/vite.config.ts +16 -0
- package/src/contract/decoder.ts +1 -0
- package/src/contract/encoder.ts +6 -1
- package/src/core/BaseDecoder.ts +118 -0
- package/src/core/BaseEncoder.ts +146 -0
- package/src/decoders/docx/DocxDecoder.ts +867 -150
- package/src/decoders/html/HtmlDecoder.ts +366 -0
- package/src/decoders/hwp/HwpScanner.ts +477 -88
- package/src/decoders/hwpx/HwpxDecoder.ts +789 -293
- package/src/decoders/md/MdDecoder.ts +4 -4
- package/src/encoders/docx/DocxEncoder.ts +600 -295
- package/src/encoders/html/HtmlEncoder.ts +203 -0
- package/src/encoders/hwp/HwpEncoder.ts +1647 -398
- package/src/encoders/hwpx/HwpxEncoder.ts +1512 -444
- package/src/encoders/hwpx/constants.ts +148 -0
- package/src/encoders/hwpx/utils.ts +198 -0
- package/src/encoders/md/MdEncoder.ts +117 -30
- package/src/index.ts +1 -0
- package/src/model/builders.ts +8 -6
- package/src/model/doc-props.ts +19 -5
- package/src/model/doc-tree.ts +13 -5
- package/src/pipeline/Pipeline.ts +21 -4
- package/src/pipeline/registry.ts +13 -2
- package/src/safety/StyleBridge.ts +52 -7
- package/src/toolkit/ArchiveKit.ts +56 -0
- package/src/toolkit/StyleMapper.ts +221 -0
- package/src/toolkit/UnitConverter.ts +138 -0
- package/src/toolkit/XmlKit.ts +0 -5
- package/test-styling.ts +210 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Decoder } from '../../contract/decoder';
|
|
2
1
|
import type { DocRoot, ContentNode, ParaNode, SpanNode, ImgNode } from '../../model/doc-tree';
|
|
3
2
|
import type { Outcome } from '../../contract/result';
|
|
4
3
|
import type { ParaProps, TextProps } from '../../model/doc-props';
|
|
@@ -8,16 +7,17 @@ import { buildRoot, buildSheet, buildPara, buildSpan, buildImg, buildGrid, build
|
|
|
8
7
|
import { ShieldedParser } from '../../safety/ShieldedParser';
|
|
9
8
|
import { TextKit } from '../../toolkit/TextKit';
|
|
10
9
|
import { registry } from '../../pipeline/registry';
|
|
10
|
+
import { BaseDecoder } from '../../core/BaseDecoder';
|
|
11
11
|
|
|
12
|
-
export class MdDecoder
|
|
13
|
-
|
|
12
|
+
export class MdDecoder extends BaseDecoder {
|
|
13
|
+
protected getFormat(): string { return 'md'; }
|
|
14
14
|
|
|
15
15
|
async decode(data: Uint8Array): Promise<Outcome<DocRoot>> {
|
|
16
16
|
const shield = new ShieldedParser();
|
|
17
17
|
const warns: string[] = [];
|
|
18
18
|
|
|
19
19
|
try {
|
|
20
|
-
const text =
|
|
20
|
+
const text = this.bytesToString(data);
|
|
21
21
|
const lines = text.split(/\r?\n/);
|
|
22
22
|
const kids: ContentNode[] = [];
|
|
23
23
|
|