@mdgate/onenote 0.6.8 → 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.
Files changed (2) hide show
  1. package/README.md +140 -10
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,29 +1,159 @@
1
1
  # @mdgate/onenote
2
2
 
3
- Convert Microsoft OneNote section and notebook files to Markdown. Outputs
4
- GitHub-Flavored Markdown. Works in Node, Edge, and browsers. No native addons.
3
+ **Convert Microsoft OneNote files to Markdown in TypeScript.**
5
4
 
6
- Handles: `.one`, `.onetoc2`, `.onepkg`
5
+ [`@mdgate/onenote`](https://github.com/mdgate/converters/tree/main/packages/onenote) reads `.one`, `.onetoc2`, and `.onepkg` files directly in JavaScript and converts page text into GitHub-Flavored Markdown, without Python, native addons, WASM, or OneNote.
7
6
 
8
- v1 is best-effort text extraction (page titles and body lines), not a full
9
- OneNote renderer.
7
+ Works in **Node.js, Cloudflare Workers, Edge runtimes, and browsers**.
10
8
 
11
- ## Usage
9
+ ```bash
10
+ npm install @mdgate/onenote
11
+ ```
12
+
13
+ ```ts
14
+ import { toMarkdown } from '@mdgate/onenote';
15
+
16
+ const markdown = await toMarkdown(bytes);
17
+ ```
18
+
19
+ `bytes` is a `Uint8Array`, so the notebook can come from a file upload, object storage, an HTTP request, a browser file picker, or anywhere else your application gets bytes.
20
+
21
+ ---
22
+
23
+ ## Why [`@mdgate/onenote`](https://github.com/mdgate/converters/tree/main/packages/onenote)
24
+
25
+ OneNote stores notes in a proprietary revision format. There is no HTML or DOCX sitting inside a typical `.one` file.
26
+
27
+ [`@mdgate/onenote`](https://github.com/mdgate/converters/tree/main/packages/onenote) is a OneNote reader written for the same runtime as your application:
28
+
29
+ * **Pure TypeScript**
30
+ * **OneNote → 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 OneNote files from their contents, not only the filename**
37
+
38
+ ---
39
+
40
+ ## What it extracts
41
+
42
+ This converter is best-effort text extraction, not a full OneNote renderer.
43
+
44
+ It collects:
45
+
46
+ * page titles when they can be recognized
47
+ * readable body lines from OLE streams or packed bytes
48
+ * `.onepkg` ZIP members: when composed with `create()`, inner `.one` files are passed back through the same reader
49
+
50
+ It does not reconstruct OneNote ink, embedded files, or exact page layout.
51
+
52
+ ---
53
+
54
+ ## Node.js
55
+
56
+ ```ts
57
+ import { readFile } from 'node:fs/promises';
58
+ import { toMarkdown } from '@mdgate/onenote';
59
+
60
+ const bytes = new Uint8Array(await readFile('meeting.one'));
61
+ const markdown = await toMarkdown(bytes);
62
+
63
+ console.log(markdown);
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Browser
69
+
70
+ ```ts
71
+ import { toMarkdown } from '@mdgate/onenote';
72
+
73
+ const file = input.files![0];
74
+ const bytes = new Uint8Array(await file.arrayBuffer());
75
+
76
+ const markdown = await toMarkdown(bytes);
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Cloudflare Workers and Edge runtimes
12
82
 
13
83
  ```ts
14
84
  import { toMarkdown } from '@mdgate/onenote';
15
85
 
86
+ export default {
87
+ async fetch(request: Request) {
88
+ const bytes = new Uint8Array(await request.arrayBuffer());
89
+ const markdown = await toMarkdown(bytes);
90
+
91
+ return new Response(markdown, {
92
+ headers: {
93
+ 'content-type': 'text/markdown; charset=utf-8',
94
+ },
95
+ });
96
+ },
97
+ };
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Format detection
103
+
104
+ You do not need to trust the file extension.
105
+
106
+ [`@mdgate/onenote`](https://github.com/mdgate/converters/tree/main/packages/onenote) recognizes OneNote OLE files and `.onepkg` ZIP packages from their contents.
107
+
108
+ ```ts
16
109
  const markdown = await toMarkdown(bytes);
17
110
  ```
18
111
 
19
- Compose with other converters:
112
+ A path can still be supplied as a format hint when [`@mdgate/onenote`](https://github.com/mdgate/converters/tree/main/packages/onenote) 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.
113
+
114
+ ---
115
+
116
+ ## Compose it with other file readers
117
+
118
+ [`@mdgate/onenote`](https://github.com/mdgate/converters/tree/main/packages/onenote) implements the converter interface from [`@mdgate/core`](https://github.com/mdgate/converters/tree/main/packages/core).
20
119
 
21
120
  ```ts
22
121
  import { create } from '@mdgate/core';
23
122
  import { onenote } from '@mdgate/onenote';
123
+ import { docx } from '@mdgate/docx';
124
+
125
+ const read = create([
126
+ onenote(),
127
+ docx(),
128
+ ]);
129
+ ```
130
+
131
+ The application still uses one reading interface while each format remains independently installable.
132
+
133
+ ---
134
+
135
+ ## Need more than OneNote?
136
+
137
+ If your application needs to read many different file types, use the complete converter set:
24
138
 
25
- const convert = create([onenote()]);
139
+ ```bash
140
+ npm install @mdgate/converters
26
141
  ```
27
142
 
28
- Part of [mdgate converters](https://github.com/mdgate/converters); install
29
- `@mdgate/converters` for every format at once.
143
+ ```ts
144
+ import { toMarkdown } from '@mdgate/converters';
145
+
146
+ const markdown = await toMarkdown(bytes, {
147
+ path: filename,
148
+ });
149
+ ```
150
+
151
+ [`@mdgate/onenote`](https://github.com/mdgate/converters/tree/main/packages/onenote) is one of the single-format packages in the open-source [`mdgate/converters`](https://github.com/mdgate/converters) project.
152
+
153
+ For AI agents, the same converter architecture can be used to extend `read_file` from text files to real-world document formats.
154
+
155
+ ---
156
+
157
+ ## License
158
+
159
+ MIT
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@mdgate/onenote",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "mdgate OneNote converter (.one / .onetoc2 / .onepkg)",
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,10 +28,10 @@
28
28
  "prepublishOnly": "bun run build"
29
29
  },
30
30
  "dependencies": {
31
- "@mdgate/containers": "0.6.8",
32
- "@mdgate/core": "0.6.8",
33
- "@mdgate/document": "0.6.8",
34
- "@mdgate/utils": "0.6.8"
31
+ "@mdgate/containers": "0.6.9",
32
+ "@mdgate/core": "0.6.9",
33
+ "@mdgate/document": "0.6.9",
34
+ "@mdgate/utils": "0.6.9"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"