@ryangarber/markitdown-ts 0.1.5 → 0.2.1
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 +21 -10
- package/dist/cli.mjs +424 -329
- package/dist/index.cjs +788 -645
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -34
- package/dist/index.d.ts +19 -34
- package/dist/index.js +398 -316
- package/dist/index.js.map +1 -1
- package/dist/markitdown.1 +30 -0
- package/package.json +39 -21
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
- ZIP archives (`.zip`), with nested files converted recursively
|
|
16
16
|
- Wikipedia, YouTube metadata, and Bing result pages supplied as HTML
|
|
17
17
|
|
|
18
|
-
Audio, image metadata, local-path, and YouTube transcript features from the original project are intentionally left out because their implementations depended on runtime-specific modules, binaries, streams, or filesystem access. They may be added back over time as alternative implementations are found.
|
|
18
|
+
Audio, image metadata, local-path, and YouTube transcript features from the original project are intentionally left out because their implementations depended on runtime-specific modules, binaries, streams, or filesystem access. They may be added back over time as alternative implementations are found. Want to see one added? Contributions are welcome!
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
|
@@ -30,22 +30,19 @@ import { MarkItDown } from "@ryangarber/markitdown-ts";
|
|
|
30
30
|
|
|
31
31
|
const bytes: Uint8Array = /* plain bytes */;
|
|
32
32
|
|
|
33
|
-
const result = await new MarkItDown().convert(bytes
|
|
34
|
-
file_extension: ".txt"
|
|
35
|
-
});
|
|
33
|
+
const result = await new MarkItDown().convert(bytes);
|
|
36
34
|
|
|
37
35
|
console.log(result?.markdown);
|
|
38
36
|
```
|
|
39
37
|
|
|
40
38
|
The same `convert` method accepts:
|
|
41
|
-
|
|
42
39
|
- `Uint8Array`
|
|
43
40
|
- `ArrayBuffer` and `SharedArrayBuffer`
|
|
44
|
-
- `DataView` or any other typed array
|
|
41
|
+
- `DataView` or any other typed array
|
|
45
42
|
- `Blob` and `File`
|
|
46
43
|
- `Response`
|
|
47
44
|
|
|
48
|
-
|
|
45
|
+
The file type is detected from, in order: the `extension` option, a `File`'s name or a Content-Disposition filename, the URL's path (the `url` option and a `Response`'s URL), a `Blob`'s type or a Content-Type header, the content's magic number, and finally the content itself (HTML, XML, RSS, Atom, notebooks, and plain text). Each candidate is tried until one converts, so pass `extension` only when the content is ambiguous.
|
|
49
46
|
|
|
50
47
|
```ts
|
|
51
48
|
const file = new File([docxBytes], "document.docx");
|
|
@@ -88,16 +85,30 @@ class MarkItDown {
|
|
|
88
85
|
|
|
89
86
|
`convertBuffer` remains as a compatibility alias, but `convert(bytes, options)` is preferred.
|
|
90
87
|
|
|
88
|
+
## CLI
|
|
89
|
+
|
|
90
|
+
The `markitdown` command converts a file and prints its Markdown:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
npx @ryangarber/markitdown-ts report.docx
|
|
94
|
+
markitdown --extension html page # when the type can't be detected
|
|
95
|
+
markitdown report.pdf --json # print { title, markdown }
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
To use it without Node, download the standalone build for your system (`markitdown-darwin-arm64`, `markitdown-darwin-x64`, `markitdown-linux-arm64`, `markitdown-linux-x64`, `markitdown-win32-arm64.exe` or `markitdown-win32-x64.exe`) from the [latest release](https://github.com/ryangarber/markitdown-ts/releases/latest), or build it from source with `pnpm build:cli` (needs [Bun](https://bun.sh)).
|
|
99
|
+
|
|
91
100
|
## Development
|
|
92
101
|
|
|
93
102
|
```sh
|
|
94
103
|
pnpm install
|
|
95
|
-
pnpm
|
|
104
|
+
pnpm lint
|
|
105
|
+
pnpm typecheck
|
|
96
106
|
pnpm test --run
|
|
97
|
-
pnpm build
|
|
107
|
+
pnpm build # library, CLI and man page
|
|
108
|
+
pnpm build:cli # standalone binaries (needs Bun)
|
|
98
109
|
```
|
|
99
110
|
|
|
100
|
-
Biome handles both formatting and linting. `
|
|
111
|
+
Biome handles both formatting and linting. `tsdown` produces ESM, CommonJS, source maps, and declarations in `dist`. Releases are cut by [rylease](https://github.com/ryangarber/rylease) from conventional commits: pushes to `main` dry-run the release, and dispatching the `release` workflow on `main` publishes to npm and attaches the CLI binaries to the GitHub release.
|
|
101
112
|
|
|
102
113
|
## License
|
|
103
114
|
|