postext-cli 0.0.0-stage → 1.22.3
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 +80 -2
- package/bin/readme.txt +78 -0
- package/npm/postext.js +29 -0
- package/package.json +35 -4
package/README.md
CHANGED
|
@@ -1,3 +1,81 @@
|
|
|
1
|
-
#
|
|
1
|
+
# postext-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**The [postext](https://postext.dev/) command line.**
|
|
4
|
+
|
|
5
|
+
`postext` turns a book written in Markdown into a PDF, HTML, an EPUB, page images or a Word file, from a terminal, a script or an agent. It is one self-contained executable per system: the Bun runtime, the postext engine, the PDF, EPUB, HTML and Word writers, the page painter (Skia), HarfBuzz, the default fonts (EB Garamond, Open Sans) and the ICC print profiles are all inside it. There is nothing to install.
|
|
6
|
+
|
|
7
|
+
## Get it
|
|
8
|
+
|
|
9
|
+
Every postext release attaches the executables to its [GitHub Release](https://github.com/drnachio/postext/releases/latest), with `SHA256SUMS` and [`readme.txt`](bin/readme.txt):
|
|
10
|
+
|
|
11
|
+
| File | System |
|
|
12
|
+
|---|---|
|
|
13
|
+
| `postext-macos-arm64` | macOS, Apple silicon |
|
|
14
|
+
| `postext-macos-x64` | macOS, Intel |
|
|
15
|
+
| `postext-linux-x64` | Linux x86-64 (glibc) |
|
|
16
|
+
| `postext-linux-arm64` | Linux ARM64 (glibc) |
|
|
17
|
+
| `postext-linux-x64-musl` | Linux x86-64, musl (Alpine: `apk add libstdc++ libgcc`) |
|
|
18
|
+
| `postext-windows-x64.exe` | Windows x64 |
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
curl -fL -o postext https://github.com/drnachio/postext/releases/latest/download/postext-linux-x64
|
|
22
|
+
chmod +x postext
|
|
23
|
+
./postext
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
With Node.js, `npx postext-cli` downloads the executable of your system from npm and runs it.
|
|
27
|
+
|
|
28
|
+
## Use
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
postext # help
|
|
32
|
+
postext help pdf # options of a command
|
|
33
|
+
postext pdf book.postext -o book.pdf
|
|
34
|
+
postext pdf book/ --pdfx x4 --profile fogra51 # print-ready PDF/X-4
|
|
35
|
+
postext html book.postext -o book.html # one self-contained page
|
|
36
|
+
postext epub book.postext --layout reflowable
|
|
37
|
+
postext image book.postext --page 12 -o p12.png
|
|
38
|
+
postext images book.postext --pages 1-10 -o pages/ --dpi 100 -f webp
|
|
39
|
+
postext docx book.postext -o book.docx
|
|
40
|
+
postext import-docx manuscript.docx -o manuscript/
|
|
41
|
+
postext pack book/ -o book.postext
|
|
42
|
+
postext unpack book.postext -o book/
|
|
43
|
+
postext info book.postext --pages
|
|
44
|
+
postext check book.postext --json
|
|
45
|
+
postext build book/ --pdf out/book.pdf --html out/book.html --watch
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
A book is any of:
|
|
49
|
+
|
|
50
|
+
- a `.postext` bundle, the file the [Sandbox](https://postext.dev/en/sandbox) exports and opens;
|
|
51
|
+
- an unpacked book folder, with its `preset.json`, chapters, resources and fonts;
|
|
52
|
+
- loose Markdown files, one chapter each, in the order given (a folder: its `.md` files by name), with an optional `--config` JSON, a `--resources` folder of pictures (each named by its file name, or described in a `resources.json`) and a `--fonts` folder.
|
|
53
|
+
|
|
54
|
+
`--set path=value` changes one setting without editing the book (`--set page.dpi=150`, `--set bodyText.fontFamily=Lora`), and `--chapters 2-4` lays out part of it.
|
|
55
|
+
|
|
56
|
+
### Fonts
|
|
57
|
+
|
|
58
|
+
A family the book does not carry is looked up in the `--font-dir` folders, then among the faces compiled in (EB Garamond, Open Sans), then in the cache, then downloaded once from Google Fonts into `~/.cache/postext` (`%LOCALAPPDATA%\postext\cache` on Windows; `POSTEXT_CACHE_DIR` or `--cache-dir` moves it). `--offline` never downloads. A family found nowhere is set in EB Garamond, with a warning, so the layout and the PDF still agree.
|
|
59
|
+
|
|
60
|
+
### Scripts and agents
|
|
61
|
+
|
|
62
|
+
- `--json` prints one JSON object on stdout: the outputs written, the page count, every warning (with the chapter file and line, and the page), and the time each step took. Messages go to stderr.
|
|
63
|
+
- Exit codes: `0` done, `1` failed, `2` wrong usage, `3` `check` found errors (or any warning with `--strict`).
|
|
64
|
+
- `-o -` writes a single output to stdout (`postext image book.postext -p 1 -o - | …`).
|
|
65
|
+
- `postext build` lays the book out once for several outputs, and `--watch` keeps the engine and the fonts loaded: a change is laid out again in a fraction of a second.
|
|
66
|
+
|
|
67
|
+
## Develop
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpm --filter postext-cli start pdf book.postext # run from the sources
|
|
71
|
+
pnpm --filter postext-cli test # bun test (units and end to end)
|
|
72
|
+
pnpm --filter postext-cli build:bin # every executable into bin/
|
|
73
|
+
pnpm --filter postext-cli build:bin --current # this machine's only
|
|
74
|
+
sh scripts/smoke.sh bin/postext-macos-arm64 # smoke test an executable
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`scripts/build-bin.ts` cross-compiles every target from one machine: it fetches Skia's native addon for each platform from npm and embeds it. The release workflow builds them, runs `scripts/smoke.sh` on Linux (glibc and Alpine), macOS and Windows runners, attaches them to the GitHub Release and publishes the npm packages (`scripts/npm-publish.mjs`).
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT. The embedded EB Garamond and Open Sans are under the SIL Open Font License ([`fonts/`](fonts/)).
|
package/bin/readme.txt
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
postext command line 1.22.3
|
|
2
|
+
===========================
|
|
3
|
+
|
|
4
|
+
One self-contained executable per system: no installation, no runtime and
|
|
5
|
+
no libraries. The postext engine, the PDF, EPUB, HTML and Word writers,
|
|
6
|
+
the page painter (Skia), the default fonts (EB Garamond, Open Sans) and the
|
|
7
|
+
print colour profiles are all inside.
|
|
8
|
+
|
|
9
|
+
Executables (115 to 140 MB each)
|
|
10
|
+
--------------------------------
|
|
11
|
+
|
|
12
|
+
postext-macos-arm64 macOS, Apple silicon (M1 and later)
|
|
13
|
+
postext-macos-x64 macOS, Intel
|
|
14
|
+
postext-linux-x64 Linux x86-64 (glibc: Debian, Ubuntu, Fedora…)
|
|
15
|
+
postext-linux-arm64 Linux ARM64 (glibc: Raspberry Pi OS 64-bit, Graviton…)
|
|
16
|
+
postext-linux-x64-musl Linux x86-64, musl (Alpine)
|
|
17
|
+
postext-windows-x64.exe Windows x64
|
|
18
|
+
|
|
19
|
+
Download the latest (every release of postext publishes them):
|
|
20
|
+
|
|
21
|
+
https://github.com/drnachio/postext/releases/latest/download/<file>
|
|
22
|
+
|
|
23
|
+
e.g. https://github.com/drnachio/postext/releases/latest/download/postext-linux-x64
|
|
24
|
+
|
|
25
|
+
or a given version: https://github.com/drnachio/postext/releases/tag/v1.22.3
|
|
26
|
+
SHA256SUMS lists the checksum of each file.
|
|
27
|
+
|
|
28
|
+
Install
|
|
29
|
+
-------
|
|
30
|
+
|
|
31
|
+
Linux and macOS:
|
|
32
|
+
|
|
33
|
+
curl -fL -o postext https://github.com/drnachio/postext/releases/latest/download/postext-linux-x64
|
|
34
|
+
chmod +x postext
|
|
35
|
+
./postext # prints the help
|
|
36
|
+
sudo mv postext /usr/local/bin # optional: run it from anywhere
|
|
37
|
+
|
|
38
|
+
Linux builds need only the C library every distribution has (glibc 2.27
|
|
39
|
+
or later; musl for Alpine, which also needs `apk add libstdc++ libgcc`).
|
|
40
|
+
|
|
41
|
+
macOS: a file downloaded with a browser is quarantined; clear the flag once:
|
|
42
|
+
|
|
43
|
+
xattr -d com.apple.quarantine postext-macos-arm64
|
|
44
|
+
|
|
45
|
+
Windows (PowerShell):
|
|
46
|
+
|
|
47
|
+
Invoke-WebRequest https://github.com/drnachio/postext/releases/latest/download/postext-windows-x64.exe -OutFile postext.exe
|
|
48
|
+
.\postext.exe
|
|
49
|
+
|
|
50
|
+
With Node.js installed, `npx postext-cli` downloads and runs the right one.
|
|
51
|
+
|
|
52
|
+
Use
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
postext help
|
|
56
|
+
postext help <command> options of a command
|
|
57
|
+
postext pdf book.postext -o book.pdf PDF
|
|
58
|
+
postext html book.postext -o book.html HTML (one self-contained file)
|
|
59
|
+
postext epub book.postext -o book.epub EPUB 3
|
|
60
|
+
postext image book.postext --page 1 -o p1.png one page as an image
|
|
61
|
+
postext images book.postext -o pages/ --dpi 100 every page
|
|
62
|
+
postext docx book.postext -o book.docx Word
|
|
63
|
+
postext import-docx draft.docx -o draft/ Word to a postext book
|
|
64
|
+
postext pack book/ -o book.postext folder (or Markdown files) to a bundle
|
|
65
|
+
postext unpack book.postext -o book/ bundle to a folder
|
|
66
|
+
postext info book.postext chapters, fonts, resources
|
|
67
|
+
postext check book.postext --json problems, as JSON for scripts and agents
|
|
68
|
+
postext build book/ --pdf b.pdf --html b.html --watch several outputs, rebuild on change
|
|
69
|
+
|
|
70
|
+
A book is a .postext file, an unpacked folder with its preset.json, or loose
|
|
71
|
+
Markdown files (one chapter each) with --config, --resources and --fonts.
|
|
72
|
+
Fonts the book does not carry are looked up in --font-dir folders, then
|
|
73
|
+
downloaded once from Google Fonts into ~/.cache/postext (--offline never
|
|
74
|
+
downloads).
|
|
75
|
+
|
|
76
|
+
Exit codes: 0 done, 1 failed, 2 wrong usage, 3 check found problems.
|
|
77
|
+
|
|
78
|
+
Docs: https://postext.dev/docs · Source: https://github.com/drnachio/postext
|
package/npm/postext.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// `npx postext-cli` / `postext` installed from npm: runs the executable of
|
|
3
|
+
// this platform, which npm installed as one of the optional dependencies
|
|
4
|
+
// (postext-cli-<os>-<arch>). The executable needs no Node.js; this file
|
|
5
|
+
// only finds it.
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const os = { darwin: 'macos', linux: 'linux', win32: 'windows' }[process.platform];
|
|
11
|
+
const arch = { arm64: 'arm64', x64: 'x64' }[process.arch];
|
|
12
|
+
const musl = process.platform === 'linux' && !process.report?.getReport()?.header?.glibcVersionRuntime;
|
|
13
|
+
const name = `postext-cli-${os}-${arch}${musl ? '-musl' : ''}`;
|
|
14
|
+
const exe = `postext${process.platform === 'win32' ? '.exe' : ''}`;
|
|
15
|
+
|
|
16
|
+
let bin;
|
|
17
|
+
try {
|
|
18
|
+
bin = require.resolve(`${name}/bin/${exe}`);
|
|
19
|
+
} catch {
|
|
20
|
+
console.error(`postext: no executable for ${process.platform}-${process.arch}${musl ? ' (musl)' : ''} (package ${name}).`);
|
|
21
|
+
console.error('Download one from https://github.com/drnachio/postext/releases/latest');
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
25
|
+
if (result.error) {
|
|
26
|
+
console.error(`postext: ${result.error.message}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
process.exit(result.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postext-cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.22.3",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"homepage": "https://postext.dev/",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/drnachio/postext.git",
|
|
9
|
+
"directory": "packages/postext-cli"
|
|
10
|
+
},
|
|
11
|
+
"description": "The postext command line: PDF, HTML, EPUB, page images and Word files from a .postext book or loose Markdown, in one self-contained executable for Linux, macOS and Windows.",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"postext",
|
|
14
|
+
"cli",
|
|
15
|
+
"pdf",
|
|
16
|
+
"epub",
|
|
17
|
+
"typesetting",
|
|
18
|
+
"markdown",
|
|
19
|
+
"book"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"bin": {
|
|
23
|
+
"postext": "npm/postext.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"npm/postext.js",
|
|
27
|
+
"bin/readme.txt"
|
|
28
|
+
],
|
|
29
|
+
"optionalDependencies": {
|
|
30
|
+
"postext-cli-macos-arm64": "1.22.3",
|
|
31
|
+
"postext-cli-macos-x64": "1.22.3",
|
|
32
|
+
"postext-cli-linux-x64": "1.22.3",
|
|
33
|
+
"postext-cli-linux-arm64": "1.22.3",
|
|
34
|
+
"postext-cli-linux-x64-musl": "1.22.3",
|
|
35
|
+
"postext-cli-windows-x64": "1.22.3"
|
|
36
|
+
}
|
|
37
|
+
}
|