@mdgate/pages 0.1.0

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 ADDED
@@ -0,0 +1,26 @@
1
+ # @mdgate/pages
2
+
3
+ Convert Apple Pages documents to Markdown. Outputs GitHub-Flavored Markdown. Works in Node, Edge, and
4
+ browsers. No native addons.
5
+
6
+ Handles: `.pages`
7
+
8
+ ## Usage
9
+
10
+ ```ts
11
+ import { toMarkdown } from '@mdgate/pages';
12
+
13
+ const markdown = await toMarkdown(bytes);
14
+ ```
15
+
16
+ Compose with other converters:
17
+
18
+ ```ts
19
+ import { create } from '@mdgate/core';
20
+ import { pages } from '@mdgate/pages';
21
+
22
+ const convert = create([pages()]);
23
+ ```
24
+
25
+ Part of [mdgate converters](https://github.com/mdgate/converters); install
26
+ `@mdgate/converters` for every format at once.
@@ -0,0 +1,2 @@
1
+ export { pages } from './pages.js';
2
+ export { toMarkdown } from './to-markdown.js';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{documentToMarkdown as d}from"@mdgate/document";import{detectIWorkKind as i}from"@mdgate/iwork-common";import{fileExtension as s}from"@mdgate/utils";import{ConvertError as p}from"@mdgate/core";import{emptyDocument as u}from"@mdgate/document";import{bodyStorageFromPages as f,openIWork as a,storageToBlocks as c}from"@mdgate/iwork-common";function m(r){let o=a(r,"pages"),e=f(o);if(e===void 0)throw p.malformed("pages document has no body storage");let n=u();return n.blocks.push(...c(o,e)),n}function t(){return{id:"pages",sniff(r,o){if(i(r)==="pages")return 2;if(o?.path!==void 0&&s(o.path)==="pages")return 1;return 0},convert(r){return{markdown:d(m(r))}}}}import{create as g}from"@mdgate/core";var C=g([t()]);function k(r,o){return C(r,o)}export{k as toMarkdown,t as pages};
@@ -0,0 +1,2 @@
1
+ import type { Converter } from '@mdgate/core';
2
+ export declare function pages(): Converter;
@@ -0,0 +1,6 @@
1
+ import { type ConvertHint } from '@mdgate/core';
2
+ /**
3
+ * Convert a single file's bytes to Markdown with the pages converter.
4
+ * `hint.path` is only a sniff hint; it is never read from disk.
5
+ */
6
+ export declare function toMarkdown(bytes: Uint8Array, hint?: ConvertHint): Promise<string>;
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@mdgate/pages",
3
+ "version": "0.1.0",
4
+ "description": "mdgate Apple Pages converter",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "files": [
17
+ "dist/**/*.js",
18
+ "dist/**/*.d.ts"
19
+ ],
20
+ "scripts": {
21
+ "build": "bun ../../scripts/build-package.ts",
22
+ "prepublishOnly": "bun run build"
23
+ },
24
+ "dependencies": {
25
+ "@mdgate/core": "0.1.3",
26
+ "@mdgate/document": "0.1.0",
27
+ "@mdgate/iwork-common": "0.1.0",
28
+ "@mdgate/utils": "0.1.2"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "engines": {
34
+ "node": ">=20"
35
+ },
36
+ "keywords": [
37
+ "mdgate",
38
+ "markdown",
39
+ "pages",
40
+ "iwork",
41
+ "apple"
42
+ ]
43
+ }