pdfmd-cli 3.18.0__tar.gz → 3.20.4__tar.gz
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.
- {pdfmd_cli-3.18.0 → pdfmd_cli-3.20.4}/PKG-INFO +144 -4
- pdfmd_cli-3.18.0/pdfmd_cli.egg-info/PKG-INFO → pdfmd_cli-3.20.4/README.md +134 -23
- {pdfmd_cli-3.18.0 → pdfmd_cli-3.20.4}/pdfmd.py +3368 -64
- pdfmd_cli-3.18.0/README.md → pdfmd_cli-3.20.4/pdfmd_cli.egg-info/PKG-INFO +163 -3
- pdfmd_cli-3.20.4/pdfmd_cli.egg-info/SOURCES.txt +34 -0
- pdfmd_cli-3.20.4/pdfmd_cli.egg-info/requires.txt +14 -0
- pdfmd_cli-3.20.4/pdfmd_cli.egg-info/top_level.txt +2 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/LICENSE +21 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/VENDORED.md +17 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/__init__.py +436 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/_kerning_data.py +4659 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/assets/fonts/DejaVuSans-LICENSE.txt +187 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/assets/fonts/DejaVuSans.ttf +0 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/ast.py +370 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/cidfont.py +511 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/embedded.py +346 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/embedded_metrics.py +102 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/emoji.py +466 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/emoji_font.py +451 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/fonts.py +490 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/html_filter.py +618 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/image_loader.py +414 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/layout.py +1663 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/parser.py +4317 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/pdf.py +1065 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/py.typed +0 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/render.py +2131 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/truetype.py +619 -0
- pdfmd_cli-3.20.4/pdfmd_inkmd/url_filter.py +233 -0
- {pdfmd_cli-3.18.0 → pdfmd_cli-3.20.4}/pyproject.toml +18 -1
- pdfmd_cli-3.20.4/tests/test_native.py +567 -0
- pdfmd_cli-3.20.4/tests/test_packaging.py +117 -0
- pdfmd_cli-3.18.0/pdfmd_cli.egg-info/SOURCES.txt +0 -10
- pdfmd_cli-3.18.0/pdfmd_cli.egg-info/requires.txt +0 -2
- pdfmd_cli-3.18.0/pdfmd_cli.egg-info/top_level.txt +0 -1
- {pdfmd_cli-3.18.0 → pdfmd_cli-3.20.4}/LICENSE +0 -0
- {pdfmd_cli-3.18.0 → pdfmd_cli-3.20.4}/pdfmd_cli.egg-info/dependency_links.txt +0 -0
- {pdfmd_cli-3.18.0 → pdfmd_cli-3.20.4}/pdfmd_cli.egg-info/entry_points.txt +0 -0
- {pdfmd_cli-3.18.0 → pdfmd_cli-3.20.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pdfmd-cli
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.20.4
|
|
4
4
|
Summary: One command from Markdown to a good-looking PDF: a Pandoc wrapper with smart defaults, project-file discovery and a multi-engine fallback chain
|
|
5
5
|
Author: Ali Perdekhan
|
|
6
6
|
License-Expression: MIT
|
|
@@ -14,8 +14,17 @@ Classifier: Topic :: Text Processing :: Markup :: LaTeX
|
|
|
14
14
|
Requires-Python: >=3.10
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
+
License-File: pdfmd_inkmd/LICENSE
|
|
18
|
+
License-File: pdfmd_inkmd/assets/fonts/DejaVuSans-LICENSE.txt
|
|
17
19
|
Requires-Dist: pyyaml
|
|
18
20
|
Requires-Dist: pypdf
|
|
21
|
+
Provides-Extra: math
|
|
22
|
+
Requires-Dist: pymd2pdf<0.7,>=0.6; python_version >= "3.11" and extra == "math"
|
|
23
|
+
Requires-Dist: matplotlib; extra == "math"
|
|
24
|
+
Provides-Extra: emoji
|
|
25
|
+
Requires-Dist: inkmd<0.6,>=0.5; extra == "emoji"
|
|
26
|
+
Provides-Extra: pandoc
|
|
27
|
+
Requires-Dist: pypandoc_binary; extra == "pandoc"
|
|
19
28
|
Dynamic: license-file
|
|
20
29
|
|
|
21
30
|
# pdfmd
|
|
@@ -78,9 +87,13 @@ To update later, run `pipx upgrade pdfmd-cli`. (The package is named
|
|
|
78
87
|
The command is still `pdfmd`. For the latest unreleased code, use `pipx
|
|
79
88
|
install git+https://github.com/aliperdehan/pdfmd`.)
|
|
80
89
|
|
|
81
|
-
`pdfmd` drives programs that pip can't install, so you
|
|
90
|
+
For the full pipeline, `pdfmd` drives programs that pip can't install, so you
|
|
91
|
+
also need (without them it still makes a plain PDF; see
|
|
92
|
+
[No Pandoc?](#no-pandoc-the-built-in-fallback) below). The quickest way, with no
|
|
93
|
+
admin rights, is `pdfmd --install full`, which puts Pandoc and Typst in pdfmd's own
|
|
94
|
+
folders; the system installers below do the same job:
|
|
82
95
|
|
|
83
|
-
- **[Pandoc](https://pandoc.org/installing.html)**
|
|
96
|
+
- **[Pandoc](https://pandoc.org/installing.html)**
|
|
84
97
|
- **at least one PDF engine**. [Typst](https://typst.app) is the quickest
|
|
85
98
|
start; a TeX distribution (MacTeX, TeX Live) gives the best results and
|
|
86
99
|
is what you need for LaTeX packages and math-heavy documents.
|
|
@@ -111,7 +124,8 @@ Office files.
|
|
|
111
124
|
<details>
|
|
112
125
|
<summary>Without pipx</summary>
|
|
113
126
|
|
|
114
|
-
`pdfmd.py` is a single file that needs Python 3.10
|
|
127
|
+
`pdfmd.py` is a single file that needs Python 3.10+ (with `pdfmd_inkmd/`
|
|
128
|
+
beside it for the no-Pandoc fallback). It also runs
|
|
115
129
|
directly, and `pyyaml`/`pypdf` are optional (features that need them are
|
|
116
130
|
skipped with a warning):
|
|
117
131
|
|
|
@@ -145,6 +159,63 @@ OK quarto (only needed for .qmd files) (/usr/local/bin/quarto)
|
|
|
145
159
|
The numbers are the fallback order, and also shortcuts: `-e 6` means
|
|
146
160
|
`-e typst`.
|
|
147
161
|
|
|
162
|
+
### No Pandoc? The built-in fallback
|
|
163
|
+
|
|
164
|
+
On a machine with no Pandoc, or Pandoc but no PDF engine, `pdfmd` does not
|
|
165
|
+
stop: it builds a plain PDF with a pure-Python renderer that `pip` installed
|
|
166
|
+
with it, and says so.
|
|
167
|
+
|
|
168
|
+
```console
|
|
169
|
+
$ pdfmd notes.md
|
|
170
|
+
NOTE Pandoc was not found: building with the built-in renderer (inkmd). The output is plain ...
|
|
171
|
+
NATIVE notes.md via inkmd
|
|
172
|
+
WARN native (inkmd): notes.md: 2 math expression(s) set as plain text (Unicode, sub/superscripts, display math centred); ...
|
|
173
|
+
OK notes.md
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
- **inkmd** is built in (vendored in `pdfmd_inkmd/`, about 2 MB, standard
|
|
177
|
+
library only, works offline, same input gives the same bytes). It reads
|
|
178
|
+
GitHub-flavoured Markdown: headings, emphasis, lists, task lists, tables,
|
|
179
|
+
code blocks, quotes, links, images, and PNG/JPEG. It cannot typeset math,
|
|
180
|
+
so formulas are set as readable text instead: Greek letters and operators
|
|
181
|
+
as Unicode, `x^2` and `x_i` as super/subscripts, `\frac{a}{b}` as `a/b`,
|
|
182
|
+
and display math (`$$...$$`, `\begin{equation}`, `aligned`) as its own
|
|
183
|
+
centred lines. No bookmarks, no page numbers.
|
|
184
|
+
- **md2pdf** ([pymd2pdf](https://pypi.org/project/pymd2pdf/), ReportLab based) is
|
|
185
|
+
used when installed, for documents with footnotes, math or a title:
|
|
186
|
+
`pdfmd --install math` (same as `pip install "pdfmd-cli[math]"`; about
|
|
187
|
+
150 MB, Python 3.11+, installs matplotlib so formulas render offline, centred,
|
|
188
|
+
as real math; the few matplotlib cannot read are set as text like inkmd's).
|
|
189
|
+
Footnotes, bookmarks and syntax-highlighted code come with it.
|
|
190
|
+
- `pdfmd --install emoji` (`pdfmd-cli[emoji]`, about 11 MB) adds the colour
|
|
191
|
+
emoji font; without it emoji print as `[rocket]`-style labels.
|
|
192
|
+
- `pdfmd --install full` leaves the fallback behind: it installs **Pandoc** (the
|
|
193
|
+
real binary from PyPI's `pypandoc_binary`, about 35 MB, also `--install pandoc`
|
|
194
|
+
/ `pdfmd-cli[pandoc]`) and **Typst** (Typst's own release from GitHub, about
|
|
195
|
+
15 MB, also `--install typst`, checked against the SHA-256 GitHub lists) into
|
|
196
|
+
pdfmd's own folders (`~/.local/share/pdfmd/bin`, `%LOCALAPPDATA%\pdfmd\bin`),
|
|
197
|
+
with no admin rights. A Pandoc or Typst already on your PATH always wins; to
|
|
198
|
+
remove them, `pip uninstall pypandoc_binary` and delete the `typst` file.
|
|
199
|
+
|
|
200
|
+
Every input is treated as GitHub-flavoured Markdown. Pandoc-only syntax is
|
|
201
|
+
converted where possible (`\newpage` and `<!-- pagebreak -->` become a page
|
|
202
|
+
break, footnotes become endnotes for inkmd, `$` prices are not mistaken for math)
|
|
203
|
+
and removed otherwise (heading and image attributes, `:::` divs, raw LaTeX,
|
|
204
|
+
`<!-- comments -->`), with one warning per kind. CSV tables
|
|
205
|
+
(`::: {.csv file="data.csv"}`) work as they do with Pandoc. The title, author and date in the
|
|
206
|
+
front matter become a title block and the PDF's own title and author; other
|
|
207
|
+
front-matter keys (`documentclass`, `header-includes`, `pdfmd-options`) are
|
|
208
|
+
listed as not used. There are no filters, preambles, citations, slides, parts or
|
|
209
|
+
report mode, and only Markdown input: for any of those, `pdfmd --install full`
|
|
210
|
+
(or `brew install pandoc typst`, `winget install JohnMacFarlane.Pandoc Typst.Typst`).
|
|
211
|
+
|
|
212
|
+
The built-in renderer is chosen automatically only when there is no Pandoc
|
|
213
|
+
route; a Pandoc build that fails never falls back to it. Ask for it with
|
|
214
|
+
`-e inkmd`, `-e md2pdf` or `-e native`, or `pdf-engine: inkmd` in `pdfmd-options`.
|
|
215
|
+
When it runs on a terminal and had to leave something out, `pdfmd` offers the
|
|
216
|
+
upgrades above (set `PDFMD_NO_PROMPT=1` to silence that; choosing "don't ask
|
|
217
|
+
again" remembers it).
|
|
218
|
+
|
|
148
219
|
## Usage
|
|
149
220
|
|
|
150
221
|
Every command below can be run from inside [`examples/`](https://github.com/aliperdehan/pdfmd/tree/main/examples/).
|
|
@@ -172,6 +243,75 @@ pdfmd lecture --to typst -o lecture.typ
|
|
|
172
243
|
pdfmd lecture -o lecture.tex # a complete, compilable .tex, not a fragment
|
|
173
244
|
```
|
|
174
245
|
|
|
246
|
+
### Stopping part-way
|
|
247
|
+
|
|
248
|
+
`--stop-at` ends the build after a stage; everything before it runs as normal:
|
|
249
|
+
|
|
250
|
+
```sh
|
|
251
|
+
pdfmd report --stop-at markdown # report.assembled.md: the parts joined into one file
|
|
252
|
+
pdfmd report --assemble-only # the same, shorter
|
|
253
|
+
pdfmd report --stop-at tex # the standalone .tex a LaTeX engine would get (= --to latex)
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
The assembled file holds just the document text (and is marked
|
|
257
|
+
`pdfmd-assembled: true`), so pdfmd never joins its parts a second time.
|
|
258
|
+
|
|
259
|
+
By default it holds just the text. `--embed-metadata` also folds in what pdfmd
|
|
260
|
+
finds beside the document (metadata, preamble, Lua filters, and the
|
|
261
|
+
bibliography and CSL files the metadata names), so the file no longer needs
|
|
262
|
+
them beside it. What the text points at otherwise (images, files a preamble
|
|
263
|
+
`\input`s) is not embedded: keep it where the document finds it, relative to
|
|
264
|
+
the assembled file.
|
|
265
|
+
|
|
266
|
+
```sh
|
|
267
|
+
pdfmd report --assemble-only --embed-metadata # metadata.yaml, preamble.tex, Lua filters, .bib/.csl
|
|
268
|
+
pdfmd report --assemble-only --embed-metadata metadata preamble # only those
|
|
269
|
+
pdfmd report --assemble-only --embed-metadata --lua-mode ref # name the filter instead of copying it
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
An embedded Lua filter sits in a `{=pdfmd}` block at the end of the file. A
|
|
273
|
+
Lua filter can run any command, so one only runs if this machine's pdfmd
|
|
274
|
+
embedded it (otherwise it is skipped with a warning, unless you pass
|
|
275
|
+
`--trust-embedded`).
|
|
276
|
+
|
|
277
|
+
`--lua-mode apply` runs the filters at assembly time instead, so the text
|
|
278
|
+
already has their effect (approximate: Pandoc re-writes the text, and a filter
|
|
279
|
+
that looks at `FORMAT` is embedded instead). `--unpack` goes the other way:
|
|
280
|
+
|
|
281
|
+
```sh
|
|
282
|
+
pdfmd report.assembled.md --unpack # filters, preamble and metadata back into report.assembled.unpacked/
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
`pdfmd` finds `report.assembled.unpacked/` beside `report.assembled.md` by
|
|
286
|
+
itself (its metadata, preambles and Lua filters), and `--unpack --slim` strips
|
|
287
|
+
the unpacked parts out of the assembled file, leaving the lean document plus
|
|
288
|
+
that folder.
|
|
289
|
+
|
|
290
|
+
A document can name its own files and set what to embed, in `pdfmd-options`:
|
|
291
|
+
|
|
292
|
+
```yaml
|
|
293
|
+
pdfmd-options:
|
|
294
|
+
yaml: [base.yaml] # metadata files (like -y); also `metadata:`, or grouped:
|
|
295
|
+
metadata:
|
|
296
|
+
preamble: my-preamble.tex
|
|
297
|
+
lua-filter: my.lua
|
|
298
|
+
embed: {lua: ref} # what --assemble-only embeds without the flag
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Plain HTML output is a fragment. For a finished page, or one file with
|
|
302
|
+
everything (images, CSS) inlined, ask for it, on the command line or in the
|
|
303
|
+
document:
|
|
304
|
+
|
|
305
|
+
```sh
|
|
306
|
+
pdfmd lecture -o lecture.html --self-contained
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
```yaml
|
|
310
|
+
pdfmd-options:
|
|
311
|
+
default-output: html # build to HTML when no format is given
|
|
312
|
+
html: {self-contained: true, css: style.css}
|
|
313
|
+
```
|
|
314
|
+
|
|
175
315
|
### Slides
|
|
176
316
|
|
|
177
317
|
```sh
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: pdfmd-cli
|
|
3
|
-
Version: 3.18.0
|
|
4
|
-
Summary: One command from Markdown to a good-looking PDF: a Pandoc wrapper with smart defaults, project-file discovery and a multi-engine fallback chain
|
|
5
|
-
Author: Ali Perdekhan
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/aliperdehan/pdfmd
|
|
8
|
-
Project-URL: Changelog, https://github.com/aliperdehan/pdfmd/blob/main/CHANGELOG.md
|
|
9
|
-
Keywords: pandoc,markdown,pdf,latex,cli
|
|
10
|
-
Classifier: Environment :: Console
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
13
|
-
Classifier: Topic :: Text Processing :: Markup :: LaTeX
|
|
14
|
-
Requires-Python: >=3.10
|
|
15
|
-
Description-Content-Type: text/markdown
|
|
16
|
-
License-File: LICENSE
|
|
17
|
-
Requires-Dist: pyyaml
|
|
18
|
-
Requires-Dist: pypdf
|
|
19
|
-
Dynamic: license-file
|
|
20
|
-
|
|
21
1
|
# pdfmd
|
|
22
2
|
|
|
23
3
|
[](https://github.com/aliperdehan/pdfmd/actions/workflows/publish.yml) [](https://pypi.org/project/pdfmd-cli/)
|
|
@@ -78,9 +58,13 @@ To update later, run `pipx upgrade pdfmd-cli`. (The package is named
|
|
|
78
58
|
The command is still `pdfmd`. For the latest unreleased code, use `pipx
|
|
79
59
|
install git+https://github.com/aliperdehan/pdfmd`.)
|
|
80
60
|
|
|
81
|
-
`pdfmd` drives programs that pip can't install, so you
|
|
61
|
+
For the full pipeline, `pdfmd` drives programs that pip can't install, so you
|
|
62
|
+
also need (without them it still makes a plain PDF; see
|
|
63
|
+
[No Pandoc?](#no-pandoc-the-built-in-fallback) below). The quickest way, with no
|
|
64
|
+
admin rights, is `pdfmd --install full`, which puts Pandoc and Typst in pdfmd's own
|
|
65
|
+
folders; the system installers below do the same job:
|
|
82
66
|
|
|
83
|
-
- **[Pandoc](https://pandoc.org/installing.html)**
|
|
67
|
+
- **[Pandoc](https://pandoc.org/installing.html)**
|
|
84
68
|
- **at least one PDF engine**. [Typst](https://typst.app) is the quickest
|
|
85
69
|
start; a TeX distribution (MacTeX, TeX Live) gives the best results and
|
|
86
70
|
is what you need for LaTeX packages and math-heavy documents.
|
|
@@ -111,7 +95,8 @@ Office files.
|
|
|
111
95
|
<details>
|
|
112
96
|
<summary>Without pipx</summary>
|
|
113
97
|
|
|
114
|
-
`pdfmd.py` is a single file that needs Python 3.10
|
|
98
|
+
`pdfmd.py` is a single file that needs Python 3.10+ (with `pdfmd_inkmd/`
|
|
99
|
+
beside it for the no-Pandoc fallback). It also runs
|
|
115
100
|
directly, and `pyyaml`/`pypdf` are optional (features that need them are
|
|
116
101
|
skipped with a warning):
|
|
117
102
|
|
|
@@ -145,6 +130,63 @@ OK quarto (only needed for .qmd files) (/usr/local/bin/quarto)
|
|
|
145
130
|
The numbers are the fallback order, and also shortcuts: `-e 6` means
|
|
146
131
|
`-e typst`.
|
|
147
132
|
|
|
133
|
+
### No Pandoc? The built-in fallback
|
|
134
|
+
|
|
135
|
+
On a machine with no Pandoc, or Pandoc but no PDF engine, `pdfmd` does not
|
|
136
|
+
stop: it builds a plain PDF with a pure-Python renderer that `pip` installed
|
|
137
|
+
with it, and says so.
|
|
138
|
+
|
|
139
|
+
```console
|
|
140
|
+
$ pdfmd notes.md
|
|
141
|
+
NOTE Pandoc was not found: building with the built-in renderer (inkmd). The output is plain ...
|
|
142
|
+
NATIVE notes.md via inkmd
|
|
143
|
+
WARN native (inkmd): notes.md: 2 math expression(s) set as plain text (Unicode, sub/superscripts, display math centred); ...
|
|
144
|
+
OK notes.md
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
- **inkmd** is built in (vendored in `pdfmd_inkmd/`, about 2 MB, standard
|
|
148
|
+
library only, works offline, same input gives the same bytes). It reads
|
|
149
|
+
GitHub-flavoured Markdown: headings, emphasis, lists, task lists, tables,
|
|
150
|
+
code blocks, quotes, links, images, and PNG/JPEG. It cannot typeset math,
|
|
151
|
+
so formulas are set as readable text instead: Greek letters and operators
|
|
152
|
+
as Unicode, `x^2` and `x_i` as super/subscripts, `\frac{a}{b}` as `a/b`,
|
|
153
|
+
and display math (`$$...$$`, `\begin{equation}`, `aligned`) as its own
|
|
154
|
+
centred lines. No bookmarks, no page numbers.
|
|
155
|
+
- **md2pdf** ([pymd2pdf](https://pypi.org/project/pymd2pdf/), ReportLab based) is
|
|
156
|
+
used when installed, for documents with footnotes, math or a title:
|
|
157
|
+
`pdfmd --install math` (same as `pip install "pdfmd-cli[math]"`; about
|
|
158
|
+
150 MB, Python 3.11+, installs matplotlib so formulas render offline, centred,
|
|
159
|
+
as real math; the few matplotlib cannot read are set as text like inkmd's).
|
|
160
|
+
Footnotes, bookmarks and syntax-highlighted code come with it.
|
|
161
|
+
- `pdfmd --install emoji` (`pdfmd-cli[emoji]`, about 11 MB) adds the colour
|
|
162
|
+
emoji font; without it emoji print as `[rocket]`-style labels.
|
|
163
|
+
- `pdfmd --install full` leaves the fallback behind: it installs **Pandoc** (the
|
|
164
|
+
real binary from PyPI's `pypandoc_binary`, about 35 MB, also `--install pandoc`
|
|
165
|
+
/ `pdfmd-cli[pandoc]`) and **Typst** (Typst's own release from GitHub, about
|
|
166
|
+
15 MB, also `--install typst`, checked against the SHA-256 GitHub lists) into
|
|
167
|
+
pdfmd's own folders (`~/.local/share/pdfmd/bin`, `%LOCALAPPDATA%\pdfmd\bin`),
|
|
168
|
+
with no admin rights. A Pandoc or Typst already on your PATH always wins; to
|
|
169
|
+
remove them, `pip uninstall pypandoc_binary` and delete the `typst` file.
|
|
170
|
+
|
|
171
|
+
Every input is treated as GitHub-flavoured Markdown. Pandoc-only syntax is
|
|
172
|
+
converted where possible (`\newpage` and `<!-- pagebreak -->` become a page
|
|
173
|
+
break, footnotes become endnotes for inkmd, `$` prices are not mistaken for math)
|
|
174
|
+
and removed otherwise (heading and image attributes, `:::` divs, raw LaTeX,
|
|
175
|
+
`<!-- comments -->`), with one warning per kind. CSV tables
|
|
176
|
+
(`::: {.csv file="data.csv"}`) work as they do with Pandoc. The title, author and date in the
|
|
177
|
+
front matter become a title block and the PDF's own title and author; other
|
|
178
|
+
front-matter keys (`documentclass`, `header-includes`, `pdfmd-options`) are
|
|
179
|
+
listed as not used. There are no filters, preambles, citations, slides, parts or
|
|
180
|
+
report mode, and only Markdown input: for any of those, `pdfmd --install full`
|
|
181
|
+
(or `brew install pandoc typst`, `winget install JohnMacFarlane.Pandoc Typst.Typst`).
|
|
182
|
+
|
|
183
|
+
The built-in renderer is chosen automatically only when there is no Pandoc
|
|
184
|
+
route; a Pandoc build that fails never falls back to it. Ask for it with
|
|
185
|
+
`-e inkmd`, `-e md2pdf` or `-e native`, or `pdf-engine: inkmd` in `pdfmd-options`.
|
|
186
|
+
When it runs on a terminal and had to leave something out, `pdfmd` offers the
|
|
187
|
+
upgrades above (set `PDFMD_NO_PROMPT=1` to silence that; choosing "don't ask
|
|
188
|
+
again" remembers it).
|
|
189
|
+
|
|
148
190
|
## Usage
|
|
149
191
|
|
|
150
192
|
Every command below can be run from inside [`examples/`](https://github.com/aliperdehan/pdfmd/tree/main/examples/).
|
|
@@ -172,6 +214,75 @@ pdfmd lecture --to typst -o lecture.typ
|
|
|
172
214
|
pdfmd lecture -o lecture.tex # a complete, compilable .tex, not a fragment
|
|
173
215
|
```
|
|
174
216
|
|
|
217
|
+
### Stopping part-way
|
|
218
|
+
|
|
219
|
+
`--stop-at` ends the build after a stage; everything before it runs as normal:
|
|
220
|
+
|
|
221
|
+
```sh
|
|
222
|
+
pdfmd report --stop-at markdown # report.assembled.md: the parts joined into one file
|
|
223
|
+
pdfmd report --assemble-only # the same, shorter
|
|
224
|
+
pdfmd report --stop-at tex # the standalone .tex a LaTeX engine would get (= --to latex)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
The assembled file holds just the document text (and is marked
|
|
228
|
+
`pdfmd-assembled: true`), so pdfmd never joins its parts a second time.
|
|
229
|
+
|
|
230
|
+
By default it holds just the text. `--embed-metadata` also folds in what pdfmd
|
|
231
|
+
finds beside the document (metadata, preamble, Lua filters, and the
|
|
232
|
+
bibliography and CSL files the metadata names), so the file no longer needs
|
|
233
|
+
them beside it. What the text points at otherwise (images, files a preamble
|
|
234
|
+
`\input`s) is not embedded: keep it where the document finds it, relative to
|
|
235
|
+
the assembled file.
|
|
236
|
+
|
|
237
|
+
```sh
|
|
238
|
+
pdfmd report --assemble-only --embed-metadata # metadata.yaml, preamble.tex, Lua filters, .bib/.csl
|
|
239
|
+
pdfmd report --assemble-only --embed-metadata metadata preamble # only those
|
|
240
|
+
pdfmd report --assemble-only --embed-metadata --lua-mode ref # name the filter instead of copying it
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
An embedded Lua filter sits in a `{=pdfmd}` block at the end of the file. A
|
|
244
|
+
Lua filter can run any command, so one only runs if this machine's pdfmd
|
|
245
|
+
embedded it (otherwise it is skipped with a warning, unless you pass
|
|
246
|
+
`--trust-embedded`).
|
|
247
|
+
|
|
248
|
+
`--lua-mode apply` runs the filters at assembly time instead, so the text
|
|
249
|
+
already has their effect (approximate: Pandoc re-writes the text, and a filter
|
|
250
|
+
that looks at `FORMAT` is embedded instead). `--unpack` goes the other way:
|
|
251
|
+
|
|
252
|
+
```sh
|
|
253
|
+
pdfmd report.assembled.md --unpack # filters, preamble and metadata back into report.assembled.unpacked/
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
`pdfmd` finds `report.assembled.unpacked/` beside `report.assembled.md` by
|
|
257
|
+
itself (its metadata, preambles and Lua filters), and `--unpack --slim` strips
|
|
258
|
+
the unpacked parts out of the assembled file, leaving the lean document plus
|
|
259
|
+
that folder.
|
|
260
|
+
|
|
261
|
+
A document can name its own files and set what to embed, in `pdfmd-options`:
|
|
262
|
+
|
|
263
|
+
```yaml
|
|
264
|
+
pdfmd-options:
|
|
265
|
+
yaml: [base.yaml] # metadata files (like -y); also `metadata:`, or grouped:
|
|
266
|
+
metadata:
|
|
267
|
+
preamble: my-preamble.tex
|
|
268
|
+
lua-filter: my.lua
|
|
269
|
+
embed: {lua: ref} # what --assemble-only embeds without the flag
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Plain HTML output is a fragment. For a finished page, or one file with
|
|
273
|
+
everything (images, CSS) inlined, ask for it, on the command line or in the
|
|
274
|
+
document:
|
|
275
|
+
|
|
276
|
+
```sh
|
|
277
|
+
pdfmd lecture -o lecture.html --self-contained
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
```yaml
|
|
281
|
+
pdfmd-options:
|
|
282
|
+
default-output: html # build to HTML when no format is given
|
|
283
|
+
html: {self-contained: true, css: style.css}
|
|
284
|
+
```
|
|
285
|
+
|
|
175
286
|
### Slides
|
|
176
287
|
|
|
177
288
|
```sh
|