@mdgate/numbers 0.6.7 → 0.6.9
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 +143 -8
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,26 +1,161 @@
|
|
|
1
1
|
# @mdgate/numbers
|
|
2
2
|
|
|
3
|
-
Convert Apple Numbers spreadsheets to Markdown
|
|
4
|
-
browsers. No native addons.
|
|
3
|
+
**Convert Apple Numbers spreadsheets to Markdown in TypeScript.**
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
[`@mdgate/numbers`](https://github.com/mdgate/converters/tree/main/packages/numbers) reads `.numbers` files directly in JavaScript and converts tables into GitHub-Flavored Markdown, without Python, native addons, WASM, or Numbers.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Works in **Node.js, Cloudflare Workers, Edge runtimes, and browsers**.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @mdgate/numbers
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { toMarkdown } from '@mdgate/numbers';
|
|
15
|
+
|
|
16
|
+
const markdown = await toMarkdown(bytes);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`bytes` is a `Uint8Array`, so the spreadsheet can come from a file upload, object storage, iCloud export, a browser file picker, or anywhere else your application gets bytes.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Why [`@mdgate/numbers`](https://github.com/mdgate/converters/tree/main/packages/numbers)
|
|
24
|
+
|
|
25
|
+
Numbers files are iWork packages. An Excel parser will not read them.
|
|
26
|
+
|
|
27
|
+
[`@mdgate/numbers`](https://github.com/mdgate/converters/tree/main/packages/numbers) is a Numbers reader written for the same runtime as your application:
|
|
28
|
+
|
|
29
|
+
* **Pure TypeScript**
|
|
30
|
+
* **Numbers → Markdown locally**
|
|
31
|
+
* **No Python runtime**
|
|
32
|
+
* **No native addons**
|
|
33
|
+
* **No WASM runtime**
|
|
34
|
+
* **Zero third-party runtime dependencies**
|
|
35
|
+
* **Works with raw `Uint8Array` input**
|
|
36
|
+
* **Detects Numbers packages from their contents, not only the filename**
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## What it extracts
|
|
41
|
+
|
|
42
|
+
[`@mdgate/numbers`](https://github.com/mdgate/converters/tree/main/packages/numbers) opens the iWork archive, reads TST table storage from IWA protobuf, and rebuilds a shared document model.
|
|
43
|
+
|
|
44
|
+
The converter handles Numbers-specific concerns including:
|
|
45
|
+
|
|
46
|
+
* sheets and tables as Markdown tables
|
|
47
|
+
* cell text in table order
|
|
48
|
+
* table structure from the iWork archive
|
|
49
|
+
|
|
50
|
+
The output is Markdown that can be searched, indexed, chunked, cached, or passed directly to an AI agent.
|
|
51
|
+
|
|
52
|
+
Excel workbooks are a different format. Use [`@mdgate/xlsx`](https://github.com/mdgate/converters/tree/main/packages/xlsx) for those.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Node.js
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { readFile } from 'node:fs/promises';
|
|
60
|
+
import { toMarkdown } from '@mdgate/numbers';
|
|
61
|
+
|
|
62
|
+
const bytes = new Uint8Array(await readFile('budget.numbers'));
|
|
63
|
+
const markdown = await toMarkdown(bytes);
|
|
64
|
+
|
|
65
|
+
console.log(markdown);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Browser
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { toMarkdown } from '@mdgate/numbers';
|
|
74
|
+
|
|
75
|
+
const file = input.files![0];
|
|
76
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
77
|
+
|
|
78
|
+
const markdown = await toMarkdown(bytes);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Cloudflare Workers and Edge runtimes
|
|
9
84
|
|
|
10
85
|
```ts
|
|
11
86
|
import { toMarkdown } from '@mdgate/numbers';
|
|
12
87
|
|
|
88
|
+
export default {
|
|
89
|
+
async fetch(request: Request) {
|
|
90
|
+
const bytes = new Uint8Array(await request.arrayBuffer());
|
|
91
|
+
const markdown = await toMarkdown(bytes);
|
|
92
|
+
|
|
93
|
+
return new Response(markdown, {
|
|
94
|
+
headers: {
|
|
95
|
+
'content-type': 'text/markdown; charset=utf-8',
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Format detection
|
|
105
|
+
|
|
106
|
+
You do not need to trust the file extension.
|
|
107
|
+
|
|
108
|
+
[`@mdgate/numbers`](https://github.com/mdgate/converters/tree/main/packages/numbers) recognizes Numbers iWork packages from ZIP / `Index.zip` contents.
|
|
109
|
+
|
|
110
|
+
```ts
|
|
13
111
|
const markdown = await toMarkdown(bytes);
|
|
14
112
|
```
|
|
15
113
|
|
|
16
|
-
|
|
114
|
+
A path can still be supplied as a format hint when [`@mdgate/numbers`](https://github.com/mdgate/converters/tree/main/packages/numbers) is used through [`@mdgate/converters`](https://github.com/mdgate/converters/tree/main/packages/converters) or a reader composed with [`@mdgate/core`](https://github.com/mdgate/converters/tree/main/packages/core), but the path is never used to read a file from disk.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Compose it with other file readers
|
|
119
|
+
|
|
120
|
+
[`@mdgate/numbers`](https://github.com/mdgate/converters/tree/main/packages/numbers) implements the converter interface from [`@mdgate/core`](https://github.com/mdgate/converters/tree/main/packages/core).
|
|
17
121
|
|
|
18
122
|
```ts
|
|
19
123
|
import { create } from '@mdgate/core';
|
|
20
124
|
import { numbers } from '@mdgate/numbers';
|
|
125
|
+
import { xlsx } from '@mdgate/xlsx';
|
|
126
|
+
|
|
127
|
+
const read = create([
|
|
128
|
+
numbers(),
|
|
129
|
+
xlsx(),
|
|
130
|
+
]);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The application still uses one reading interface while each format remains independently installable.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Need more than Numbers?
|
|
138
|
+
|
|
139
|
+
If your application needs to read many different file types, use the complete converter set:
|
|
21
140
|
|
|
22
|
-
|
|
141
|
+
```bash
|
|
142
|
+
npm install @mdgate/converters
|
|
23
143
|
```
|
|
24
144
|
|
|
25
|
-
|
|
26
|
-
|
|
145
|
+
```ts
|
|
146
|
+
import { toMarkdown } from '@mdgate/converters';
|
|
147
|
+
|
|
148
|
+
const markdown = await toMarkdown(bytes, {
|
|
149
|
+
path: filename,
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
[`@mdgate/numbers`](https://github.com/mdgate/converters/tree/main/packages/numbers) is one of the single-format packages in the open-source [`mdgate/converters`](https://github.com/mdgate/converters) project.
|
|
154
|
+
|
|
155
|
+
For AI agents, the same converter architecture can be used to extend `read_file` from text files to real-world document formats.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdgate/numbers",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"description": "mdgate Apple Numbers converter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://convert.mdgate.dev",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/mdgate/converters.git",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"prepublishOnly": "bun run build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@mdgate/core": "0.6.
|
|
32
|
-
"@mdgate/document": "0.6.
|
|
33
|
-
"@mdgate/iwork-common": "0.6.
|
|
34
|
-
"@mdgate/utils": "0.6.
|
|
31
|
+
"@mdgate/core": "0.6.9",
|
|
32
|
+
"@mdgate/document": "0.6.9",
|
|
33
|
+
"@mdgate/iwork-common": "0.6.9",
|
|
34
|
+
"@mdgate/utils": "0.6.9"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|