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.
Files changed (40) hide show
  1. package/ .npmignore +4 -1
  2. package/README.md +39 -2
  3. package/dist/index.d.mts +74 -16
  4. package/dist/index.d.ts +70 -16
  5. package/dist/index.js +4985 -698
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +4981 -698
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +4 -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 +867 -150
  18. package/src/decoders/html/HtmlDecoder.ts +366 -0
  19. package/src/decoders/hwp/HwpScanner.ts +477 -88
  20. package/src/decoders/hwpx/HwpxDecoder.ts +789 -293
  21. package/src/decoders/md/MdDecoder.ts +4 -4
  22. package/src/encoders/docx/DocxEncoder.ts +600 -295
  23. package/src/encoders/html/HtmlEncoder.ts +203 -0
  24. package/src/encoders/hwp/HwpEncoder.ts +1647 -398
  25. package/src/encoders/hwpx/HwpxEncoder.ts +1512 -444
  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 +117 -30
  29. package/src/index.ts +1 -0
  30. package/src/model/builders.ts +8 -6
  31. package/src/model/doc-props.ts +19 -5
  32. package/src/model/doc-tree.ts +13 -5
  33. package/src/pipeline/Pipeline.ts +21 -4
  34. package/src/pipeline/registry.ts +13 -2
  35. package/src/safety/StyleBridge.ts +52 -7
  36. package/src/toolkit/ArchiveKit.ts +56 -0
  37. package/src/toolkit/StyleMapper.ts +221 -0
  38. package/src/toolkit/UnitConverter.ts +138 -0
  39. package/src/toolkit/XmlKit.ts +0 -5
  40. 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 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