hwpkit-dev 0.0.2 → 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.
Files changed (43) hide show
  1. package/ .npmignore +4 -2
  2. package/README.md +39 -2
  3. package/dist/index.d.mts +41 -14
  4. package/dist/index.d.ts +41 -14
  5. package/dist/index.js +3553 -1159
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +3553 -1159
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +2 -1
  10. package/playground/index.html +346 -0
  11. package/playground/main.ts +302 -0
  12. package/playground/vite.config.ts +16 -0
  13. package/src/contract/decoder.ts +1 -0
  14. package/src/contract/encoder.ts +6 -1
  15. package/src/core/BaseDecoder.ts +118 -0
  16. package/src/core/BaseEncoder.ts +146 -0
  17. package/src/decoders/docx/DocxDecoder.ts +743 -151
  18. package/src/decoders/html/HtmlDecoder.ts +366 -0
  19. package/src/decoders/hwp/HwpScanner.ts +325 -157
  20. package/src/decoders/hwpx/HwpxDecoder.ts +785 -297
  21. package/src/decoders/md/MdDecoder.ts +4 -4
  22. package/src/encoders/docx/DocxEncoder.ts +504 -240
  23. package/src/encoders/html/HtmlEncoder.ts +17 -19
  24. package/src/encoders/hwp/HwpEncoder.ts +1466 -859
  25. package/src/encoders/hwpx/HwpxEncoder.ts +1477 -469
  26. package/src/encoders/hwpx/constants.ts +148 -0
  27. package/src/encoders/hwpx/utils.ts +198 -0
  28. package/src/encoders/md/MdEncoder.ts +20 -15
  29. package/src/model/builders.ts +4 -4
  30. package/src/model/doc-props.ts +19 -5
  31. package/src/model/doc-tree.ts +12 -4
  32. package/src/pipeline/Pipeline.ts +7 -3
  33. package/src/pipeline/registry.ts +13 -2
  34. package/src/safety/StyleBridge.ts +51 -6
  35. package/src/toolkit/ArchiveKit.ts +56 -0
  36. package/src/toolkit/StyleMapper.ts +221 -0
  37. package/src/toolkit/UnitConverter.ts +138 -0
  38. package/src/toolkit/XmlKit.ts +0 -5
  39. package/test-styling.ts +210 -0
  40. package/hwp-analyze.ts +0 -90
  41. package/inspect-doc.ts +0 -57
  42. package/output_test.hwp +0 -0
  43. package/test-docx-to-hwp.ts +0 -45
@@ -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 implements Decoder {
13
- readonly format = 'md';
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 = TextKit.decode(data);
20
+ const text = this.bytesToString(data);
21
21
  const lines = text.split(/\r?\n/);
22
22
  const kids: ContentNode[] = [];
23
23