@mdgate/converters 0.6.8 → 0.6.10

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 (2) hide show
  1. package/README.md +183 -45
  2. package/package.json +33 -33
package/README.md CHANGED
@@ -1,63 +1,201 @@
1
1
  # @mdgate/converters
2
2
 
3
- Official mdgate converter bundle: every format converter in one install.
3
+ [![npm](https://img.shields.io/npm/v/@mdgate/converters.svg)](https://www.npmjs.com/package/@mdgate/converters)
4
+ [![downloads](https://img.shields.io/npm/dm/@mdgate/converters.svg)](https://www.npmjs.com/package/@mdgate/converters)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-teal.svg)](LICENSE)
6
+ [![convert](https://img.shields.io/badge/convert-convert.mdgate.dev-0f766e)](https://convert.mdgate.dev)
4
7
 
5
- [Try the in-browser demo](https://demo.mdgate.dev). Full docs live in the
6
- [repository README](https://github.com/mdgate/converters#readme).
8
+ **Real-world files to Markdown, in pure TypeScript.**
9
+
10
+ [`@mdgate/converters`](https://github.com/mdgate/converters/tree/main/packages/converters) is the complete deterministic reader: one `toMarkdown(bytes)` for PDF, Word, Excel, PowerPoint, OpenDocument, Apple iWork, HWP, WPS, email, OneNote, Visio, ebooks, archives, and more.
11
+
12
+ Works in **Node.js, Cloudflare Workers, Edge runtimes, and browsers**.
13
+
14
+ **No Python. No native addons. No WASM. No third-party runtime dependencies.**
15
+
16
+ ```bash
17
+ npm install @mdgate/converters
18
+ ```
7
19
 
8
20
  ```ts
9
21
  import { toMarkdown } from '@mdgate/converters';
10
22
 
11
- const markdown = await toMarkdown(bytes, { path: 'notes.docx' });
23
+ const markdown = await toMarkdown(bytes, {
24
+ path: 'report.docx',
25
+ });
26
+ ```
27
+
28
+ The input is bytes. The output is Markdown.
29
+
30
+ [Convert a file in your browser](https://convert.mdgate.dev). Full docs live in the [repository README](https://github.com/mdgate/converters#readme).
31
+
32
+ ---
33
+
34
+ ## Why [`@mdgate/converters`](https://github.com/mdgate/converters/tree/main/packages/converters)
35
+
36
+ A JavaScript application that needs to read real-world files quickly becomes a collection of unrelated parsers.
37
+
38
+ This package puts them behind one interface:
39
+
40
+ ```text
41
+ Uint8Array → Markdown
12
42
  ```
13
43
 
14
- Or compose converters yourself:
44
+ `toMarkdown` is `create(all())`. `all()` registers every converter that needs no configuration. Raster images, audio, and video need callbacks, so they are exported but not included in `all()`.
45
+
46
+ ---
47
+
48
+ ## One format
49
+
50
+ If your application only needs one format, install only that converter.
51
+
52
+ ```bash
53
+ npm install @mdgate/pdf
54
+ ```
15
55
 
16
56
  ```ts
17
- import { all, create } from '@mdgate/converters';
57
+ import { toMarkdown } from '@mdgate/pdf';
18
58
 
19
- const convert = create(all());
59
+ const markdown = await toMarkdown(bytes);
20
60
  ```
21
61
 
22
- `all()` registers every converter that needs no configuration. `image()`,
23
- `audio()`, and `video()` need callbacks, so they are exported but not included
24
- in `all()`.
62
+ ---
63
+
64
+ ## Your own set
65
+
66
+ ```ts
67
+ import { create } from '@mdgate/core';
68
+ import { pdf } from '@mdgate/pdf';
69
+ import { docx } from '@mdgate/docx';
70
+ import { xlsx } from '@mdgate/xlsx';
71
+
72
+ const read = create([
73
+ pdf(),
74
+ docx(),
75
+ xlsx(),
76
+ ]);
77
+ ```
25
78
 
26
- Only need one format? Install just that package instead — for example
27
- `@mdgate/docx` — and call its identical `toMarkdown`.
79
+ Or start from `all()` and add media callbacks:
80
+
81
+ ```ts
82
+ import { all, create, image } from '@mdgate/converters';
83
+ import { ai } from '@mdgate/ai';
84
+
85
+ const media = ai({
86
+ baseURL: 'https://api.example.com/v1',
87
+ apiKey: process.env.API_KEY!,
88
+ model: 'your-model',
89
+ });
90
+
91
+ const read = create([
92
+ ...all(),
93
+ image(media.convertImage),
94
+ ]);
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Node.js
100
+
101
+ ```ts
102
+ import { readFile } from 'node:fs/promises';
103
+ import { toMarkdown } from '@mdgate/converters';
104
+
105
+ const bytes = new Uint8Array(await readFile('report.docx'));
106
+ const markdown = await toMarkdown(bytes, {
107
+ path: 'report.docx',
108
+ });
109
+ ```
110
+
111
+ The optional `path` is a format hint. The converter never reads that path from disk.
112
+
113
+ ---
114
+
115
+ ## Cloudflare Workers and Edge runtimes
116
+
117
+ ```ts
118
+ import { toMarkdown } from '@mdgate/converters';
119
+
120
+ export default {
121
+ async fetch(request: Request) {
122
+ const bytes = new Uint8Array(await request.arrayBuffer());
123
+ const markdown = await toMarkdown(bytes, {
124
+ path: request.headers.get('x-filename') ?? undefined,
125
+ });
126
+
127
+ return new Response(markdown, {
128
+ headers: {
129
+ 'content-type': 'text/markdown; charset=utf-8',
130
+ },
131
+ });
132
+ },
133
+ };
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Browser
139
+
140
+ ```ts
141
+ import { toMarkdown } from '@mdgate/converters';
142
+
143
+ const file = input.files![0];
144
+ const bytes = new Uint8Array(await file.arrayBuffer());
145
+
146
+ const markdown = await toMarkdown(bytes, {
147
+ path: file.name,
148
+ });
149
+ ```
150
+
151
+ [Try it in your browser](https://convert.mdgate.dev)
152
+
153
+ ---
154
+
155
+ ## Packages
28
156
 
29
157
  | Package | Handles |
30
158
  |---|---|
31
- | `@mdgate/converters` | Bundle: every format below, `toMarkdown`, `all()` |
32
- | `@mdgate/docx` | docx, docm |
33
- | `@mdgate/doc` | doc (binary Word) |
34
- | `@mdgate/rtf` | rtf |
35
- | `@mdgate/pptx` | pptx, pptm, ppsx, ppsm |
36
- | `@mdgate/ppt` | ppt, pps, pot (binary PowerPoint) |
37
- | `@mdgate/xlsx` | xlsx, xlsm, xlsb, xls |
38
- | `@mdgate/csv` | csv |
39
- | `@mdgate/text` | txt, md, and source files |
40
- | `@mdgate/data` | json, jsonl, xml, yaml |
41
- | `@mdgate/subtitle` | srt, vtt, webvtt, ass, lrc, sub, sbv, ttml, jss |
42
- | `@mdgate/html` | html, htm, html4, html5, xhtml, mhtml, mht |
43
- | `@mdgate/email` | eml, msg, mbox, emlx |
44
- | `@mdgate/ipynb` | ipynb (Jupyter) |
45
- | `@mdgate/odf` | odt, ods, odp |
46
- | `@mdgate/pages` | pages |
47
- | `@mdgate/numbers` | numbers |
48
- | `@mdgate/keynote` | key |
49
- | `@mdgate/epub` | epub, ibooks |
50
- | `@mdgate/pdf` | pdf |
51
- | `@mdgate/fb2` | fb2, fb2.zip |
52
- | `@mdgate/mobi` | mobi, azw, azw3, prc |
53
- | `@mdgate/latex` | tex, latex, ltx |
54
- | `@mdgate/visio` | vsd, vsdx, vss, vst, vssx, vstx |
55
- | `@mdgate/onenote` | one, onetoc2, onepkg |
56
- | `@mdgate/hwp` | hwp, hwpx, hwt, hwtx |
57
- | `@mdgate/wps` | wps, wpt, et, ett, dps, dpt |
58
- | `@mdgate/zip` | zip, zipx, jar |
59
- | `@mdgate/image` | jpeg\*, png\*, webp\*, gif\*, tiff\*, heic\*, bmp\*, svg, svgz |
60
- | `@mdgate/audio` | mp3\*, wav\*, m4a\*, aac\*, ogg\*, flac\*, weba\* |
61
- | `@mdgate/video` | mp4\*, m4v\*, mov\*, webm\*, mkv\*, avi\* |
62
-
63
- \* Needs a callback vision for raster images (`image()`), transcription for audio (`audio()`), video understanding for `video()`. Not registered by `all()`. SVG converts locally.
159
+ | [`@mdgate/converters`](https://github.com/mdgate/converters/tree/main/packages/converters) | Bundle: every deterministic format below, `toMarkdown`, `all()` |
160
+ | [`@mdgate/docx`](https://github.com/mdgate/converters/tree/main/packages/docx) | docx, docm |
161
+ | [`@mdgate/doc`](https://github.com/mdgate/converters/tree/main/packages/doc) | doc (binary Word) |
162
+ | [`@mdgate/rtf`](https://github.com/mdgate/converters/tree/main/packages/rtf) | rtf |
163
+ | [`@mdgate/pptx`](https://github.com/mdgate/converters/tree/main/packages/pptx) | pptx, pptm, ppsx, ppsm |
164
+ | [`@mdgate/ppt`](https://github.com/mdgate/converters/tree/main/packages/ppt) | ppt, pps, pot (binary PowerPoint) |
165
+ | [`@mdgate/xlsx`](https://github.com/mdgate/converters/tree/main/packages/xlsx) | xlsx, xlsm, xlsb, xls |
166
+ | [`@mdgate/csv`](https://github.com/mdgate/converters/tree/main/packages/csv) | csv |
167
+ | [`@mdgate/text`](https://github.com/mdgate/converters/tree/main/packages/text) | txt, md, and source files |
168
+ | [`@mdgate/data`](https://github.com/mdgate/converters/tree/main/packages/data) | json, jsonl, xml, yaml |
169
+ | [`@mdgate/subtitle`](https://github.com/mdgate/converters/tree/main/packages/subtitle) | srt, vtt, webvtt, ass, lrc, sub, sbv, ttml, jss |
170
+ | [`@mdgate/html`](https://github.com/mdgate/converters/tree/main/packages/html) | html, htm, html4, html5, xhtml, mhtml, mht |
171
+ | [`@mdgate/email`](https://github.com/mdgate/converters/tree/main/packages/email) | eml, msg, mbox, emlx |
172
+ | [`@mdgate/ipynb`](https://github.com/mdgate/converters/tree/main/packages/ipynb) | ipynb (Jupyter) |
173
+ | [`@mdgate/odf`](https://github.com/mdgate/converters/tree/main/packages/odf) | odt, ods, odp, odg |
174
+ | [`@mdgate/pages`](https://github.com/mdgate/converters/tree/main/packages/pages) | pages |
175
+ | [`@mdgate/numbers`](https://github.com/mdgate/converters/tree/main/packages/numbers) | numbers |
176
+ | [`@mdgate/keynote`](https://github.com/mdgate/converters/tree/main/packages/keynote) | key |
177
+ | [`@mdgate/epub`](https://github.com/mdgate/converters/tree/main/packages/epub) | epub, ibooks |
178
+ | [`@mdgate/pdf`](https://github.com/mdgate/converters/tree/main/packages/pdf) | pdf |
179
+ | [`@mdgate/fb2`](https://github.com/mdgate/converters/tree/main/packages/fb2) | fb2, fb2.zip |
180
+ | [`@mdgate/mobi`](https://github.com/mdgate/converters/tree/main/packages/mobi) | mobi, azw, azw3, prc |
181
+ | [`@mdgate/latex`](https://github.com/mdgate/converters/tree/main/packages/latex) | tex, latex, ltx |
182
+ | [`@mdgate/visio`](https://github.com/mdgate/converters/tree/main/packages/visio) | vsd, vsdx, vss, vst, vssx, vstx |
183
+ | [`@mdgate/onenote`](https://github.com/mdgate/converters/tree/main/packages/onenote) | one, onetoc2, onepkg |
184
+ | [`@mdgate/hwp`](https://github.com/mdgate/converters/tree/main/packages/hwp) | hwp, hwpx, hwt, hwtx |
185
+ | [`@mdgate/wps`](https://github.com/mdgate/converters/tree/main/packages/wps) | wps, wpt, et, ett, dps, dpt |
186
+ | [`@mdgate/zip`](https://github.com/mdgate/converters/tree/main/packages/zip) | zip, zipx, jar |
187
+ | [`@mdgate/image`](https://github.com/mdgate/converters/tree/main/packages/image) | jpeg\*, png\*, webp\*, gif\*, tiff\*, heic\*, bmp\*, svg, svgz |
188
+ | [`@mdgate/audio`](https://github.com/mdgate/converters/tree/main/packages/audio) | mp3\*, wav\*, m4a\*, aac\*, ogg\*, flac\*, weba\* |
189
+ | [`@mdgate/video`](https://github.com/mdgate/converters/tree/main/packages/video) | mp4\*, m4v\*, mov\*, webm\*, mkv\*, avi\* |
190
+
191
+ \* Needs a callback: vision for raster images (`image()`), transcription for audio (`audio()`), video understanding for `video()`. Not registered by `all()`. SVG converts locally.
192
+
193
+ [`@mdgate/converters`](https://github.com/mdgate/converters/tree/main/packages/converters) is the complete reader in the open-source [`mdgate/converters`](https://github.com/mdgate/converters) project.
194
+
195
+ For AI agents, the same converter architecture can be used to extend `read_file` from text files to real-world document formats.
196
+
197
+ ---
198
+
199
+ ## License
200
+
201
+ MIT
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@mdgate/converters",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "Official mdgate converter bundle",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "homepage": "https://demo.mdgate.dev",
7
+ "homepage": "https://convert.mdgate.dev",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/mdgate/converters.git",
@@ -28,37 +28,37 @@
28
28
  "prepublishOnly": "bun run build"
29
29
  },
30
30
  "dependencies": {
31
- "@mdgate/audio": "0.6.8",
32
- "@mdgate/core": "0.6.8",
33
- "@mdgate/csv": "0.6.8",
34
- "@mdgate/data": "0.6.8",
35
- "@mdgate/doc": "0.6.8",
36
- "@mdgate/docx": "0.6.8",
37
- "@mdgate/email": "0.6.8",
38
- "@mdgate/epub": "0.6.8",
39
- "@mdgate/fb2": "0.6.8",
40
- "@mdgate/html": "0.6.8",
41
- "@mdgate/hwp": "0.6.8",
42
- "@mdgate/image": "0.6.8",
43
- "@mdgate/ipynb": "0.6.8",
44
- "@mdgate/keynote": "0.6.8",
45
- "@mdgate/latex": "0.6.8",
46
- "@mdgate/mobi": "0.6.8",
47
- "@mdgate/numbers": "0.6.8",
48
- "@mdgate/odf": "0.6.8",
49
- "@mdgate/onenote": "0.6.8",
50
- "@mdgate/pages": "0.6.8",
51
- "@mdgate/pdf": "0.6.8",
52
- "@mdgate/ppt": "0.6.8",
53
- "@mdgate/pptx": "0.6.8",
54
- "@mdgate/rtf": "0.6.8",
55
- "@mdgate/subtitle": "0.6.8",
56
- "@mdgate/text": "0.6.8",
57
- "@mdgate/video": "0.6.8",
58
- "@mdgate/visio": "0.6.8",
59
- "@mdgate/wps": "0.6.8",
60
- "@mdgate/xlsx": "0.6.8",
61
- "@mdgate/zip": "0.6.8"
31
+ "@mdgate/audio": "0.6.10",
32
+ "@mdgate/core": "0.6.10",
33
+ "@mdgate/csv": "0.6.10",
34
+ "@mdgate/data": "0.6.10",
35
+ "@mdgate/doc": "0.6.10",
36
+ "@mdgate/docx": "0.6.10",
37
+ "@mdgate/email": "0.6.10",
38
+ "@mdgate/epub": "0.6.10",
39
+ "@mdgate/fb2": "0.6.10",
40
+ "@mdgate/html": "0.6.10",
41
+ "@mdgate/hwp": "0.6.10",
42
+ "@mdgate/image": "0.6.10",
43
+ "@mdgate/ipynb": "0.6.10",
44
+ "@mdgate/keynote": "0.6.10",
45
+ "@mdgate/latex": "0.6.10",
46
+ "@mdgate/mobi": "0.6.10",
47
+ "@mdgate/numbers": "0.6.10",
48
+ "@mdgate/odf": "0.6.10",
49
+ "@mdgate/onenote": "0.6.10",
50
+ "@mdgate/pages": "0.6.10",
51
+ "@mdgate/pdf": "0.6.10",
52
+ "@mdgate/ppt": "0.6.10",
53
+ "@mdgate/pptx": "0.6.10",
54
+ "@mdgate/rtf": "0.6.10",
55
+ "@mdgate/subtitle": "0.6.10",
56
+ "@mdgate/text": "0.6.10",
57
+ "@mdgate/video": "0.6.10",
58
+ "@mdgate/visio": "0.6.10",
59
+ "@mdgate/wps": "0.6.10",
60
+ "@mdgate/xlsx": "0.6.10",
61
+ "@mdgate/zip": "0.6.10"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"