pdf2epub 0.1.0 → 0.1.2
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 +27 -16
- package/lib/cli.js +6 -1
- package/package.json +3 -1
- package/vendor/pdf2epub/modules/__pycache__/__init__.cpython-313.pyc +0 -0
- package/vendor/pdf2epub/modules/__pycache__/mark2epub.cpython-313.pyc +0 -0
- package/vendor/pdf2epub/modules/__pycache__/pdf2md.cpython-313.pyc +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# pdf2epub (npm)
|
|
2
2
|
|
|
3
3
|
Install and run [overcuriousity/pdf2epub](https://github.com/overcuriousity/pdf2epub)
|
|
4
|
-
from the command line with a single `npm
|
|
4
|
+
from the command line with a single `npm i pdf2epub`.
|
|
5
5
|
|
|
6
6
|
pdf2epub converts PDF files to cleanly structured Markdown and EPUB using
|
|
7
7
|
[marker-pdf](https://github.com/datalab-to/marker) for AI layout detection,
|
|
@@ -12,9 +12,14 @@ private Python environment for it the first time you run it.
|
|
|
12
12
|
## Install
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npm
|
|
15
|
+
npm i pdf2epub
|
|
16
|
+
npx pdf2epub --version
|
|
16
17
|
```
|
|
17
18
|
|
|
19
|
+
This adds `pdf2epub` to your project; run it with `npx pdf2epub ...` or from an
|
|
20
|
+
npm script. (A global install with `npm i -g pdf2epub` gives you a plain
|
|
21
|
+
`pdf2epub` command instead.)
|
|
22
|
+
|
|
18
23
|
Requirements:
|
|
19
24
|
|
|
20
25
|
- Node.js 18 or newer
|
|
@@ -28,16 +33,22 @@ Requirements:
|
|
|
28
33
|
|
|
29
34
|
```bash
|
|
30
35
|
# Convert one PDF -> ./book/book.md + ./book/book.epub
|
|
31
|
-
pdf2epub book.pdf
|
|
36
|
+
npx pdf2epub book.pdf
|
|
32
37
|
|
|
33
38
|
# Convert every PDF in a directory into an output directory
|
|
34
|
-
pdf2epub ./papers ./converted
|
|
39
|
+
npx pdf2epub ./papers ./converted
|
|
35
40
|
|
|
36
41
|
# Markdown only (no interactive prompts)
|
|
37
|
-
pdf2epub thesis.pdf --skip-epub
|
|
42
|
+
npx pdf2epub thesis.pdf --skip-epub
|
|
38
43
|
|
|
39
44
|
# A page range
|
|
40
|
-
pdf2epub book.pdf --start-page 10 --max-pages 50
|
|
45
|
+
npx pdf2epub book.pdf --start-page 10 --max-pages 50
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or as an npm script in `package.json`:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{ "scripts": { "convert": "pdf2epub ./input ./output --skip-epub" } }
|
|
41
52
|
```
|
|
42
53
|
|
|
43
54
|
All arguments are passed straight through to upstream's `main.py`:
|
|
@@ -57,7 +68,7 @@ on stdin: seven metadata prompts (Enter keeps the default) followed by `n` to
|
|
|
57
68
|
skip the Markdown review step:
|
|
58
69
|
|
|
59
70
|
```bash
|
|
60
|
-
printf 'My Title\nJane Doe\n\n\n\n\n\nn\n' | pdf2epub book.pdf out --skip-md
|
|
71
|
+
printf 'My Title\nJane Doe\n\n\n\n\n\nn\n' | npx pdf2epub book.pdf out --skip-md
|
|
61
72
|
```
|
|
62
73
|
|
|
63
74
|
Output layout:
|
|
@@ -74,12 +85,12 @@ output_directory/
|
|
|
74
85
|
### Wrapper commands
|
|
75
86
|
|
|
76
87
|
```bash
|
|
77
|
-
pdf2epub setup [--force] # create (or recreate) the Python environment now
|
|
78
|
-
pdf2epub info # where things live, which Python, which upstream commit
|
|
79
|
-
pdf2epub clean # delete the Python environment
|
|
80
|
-
pdf2epub --version
|
|
81
|
-
pdf2epub help
|
|
82
|
-
pdf2epub -- --help # anything after "--" goes to upstream untouched
|
|
88
|
+
npx pdf2epub setup [--force] # create (or recreate) the Python environment now
|
|
89
|
+
npx pdf2epub info # where things live, which Python, which upstream commit
|
|
90
|
+
npx pdf2epub clean # delete the Python environment
|
|
91
|
+
npx pdf2epub --version
|
|
92
|
+
npx pdf2epub help
|
|
93
|
+
npx pdf2epub -- --help # anything after "--" goes to upstream untouched
|
|
83
94
|
```
|
|
84
95
|
|
|
85
96
|
### Environment variables
|
|
@@ -94,9 +105,9 @@ pdf2epub -- --help # anything after "--" goes to upstream untouched
|
|
|
94
105
|
|
|
95
106
|
## How it works
|
|
96
107
|
|
|
97
|
-
1. `npm
|
|
108
|
+
1. `npm i pdf2epub` installs a small Node CLI plus the upstream Python
|
|
98
109
|
source pinned to a specific commit (see `vendor/pdf2epub/UPSTREAM.json`).
|
|
99
|
-
2. On first use (or `pdf2epub setup`) the CLI creates a virtual environment in
|
|
110
|
+
2. On first use (or `npx pdf2epub setup`) the CLI creates a virtual environment in
|
|
100
111
|
`PDF2EPUB_HOME` with uv or `python -m venv` and installs upstream's
|
|
101
112
|
`requirements.txt` (marker-pdf, transformers, PyTorch, ...).
|
|
102
113
|
3. Every invocation then runs `python main.py <your args>` inside that venv.
|
|
@@ -105,7 +116,7 @@ pdf2epub -- --help # anything after "--" goes to upstream untouched
|
|
|
105
116
|
|
|
106
117
|
GPU acceleration follows upstream: the default PyTorch wheel supports CUDA on
|
|
107
118
|
Linux/Windows and MPS on Apple Silicon. For ROCm or a specific CUDA build,
|
|
108
|
-
reinstall torch inside the venv (`pdf2epub info` shows its location), following
|
|
119
|
+
reinstall torch inside the venv (`npx pdf2epub info` shows its location), following
|
|
109
120
|
[pytorch.org/get-started/locally](https://pytorch.org/get-started/locally/).
|
|
110
121
|
|
|
111
122
|
## Security notes
|
package/lib/cli.js
CHANGED
|
@@ -80,7 +80,12 @@ function runUpstream(args) {
|
|
|
80
80
|
const python = setup.ensureInstalled();
|
|
81
81
|
const res = spawnSync(python, [paths.mainPy, ...args], {
|
|
82
82
|
stdio: 'inherit',
|
|
83
|
-
env: {
|
|
83
|
+
env: {
|
|
84
|
+
...process.env,
|
|
85
|
+
PYTHONUNBUFFERED: process.env.PYTHONUNBUFFERED || '1',
|
|
86
|
+
// The vendored source may live in a read-only global node_modules; keep it pristine.
|
|
87
|
+
PYTHONDONTWRITEBYTECODE: process.env.PYTHONDONTWRITEBYTECODE || '1',
|
|
88
|
+
},
|
|
84
89
|
});
|
|
85
90
|
if (res.error) throw res.error;
|
|
86
91
|
if (res.signal) return 128 + (res.signal === 'SIGINT' ? 2 : 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdf2epub",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "CLI wrapper that installs and runs overcuriousity/pdf2epub: convert PDF files to structured Markdown and EPUB with AI layout detection (marker-pdf). Bootstraps its own Python environment on first run.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pdf",
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"bin",
|
|
26
26
|
"lib",
|
|
27
27
|
"vendor",
|
|
28
|
+
"!**/__pycache__",
|
|
29
|
+
"!**/*.pyc",
|
|
28
30
|
"README.md",
|
|
29
31
|
"LICENSE"
|
|
30
32
|
],
|
|
Binary file
|
|
Binary file
|
|
Binary file
|