pdfmd-cli 3.21.5__tar.gz → 3.23.17__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.21.5/pdfmd_cli.egg-info → pdfmd_cli-3.23.17}/PKG-INFO +305 -10
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/README.md +300 -8
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd.py +3786 -144
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17/pdfmd_cli.egg-info}/PKG-INFO +305 -10
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_cli.egg-info/SOURCES.txt +18 -1
- pdfmd_cli-3.23.17/pdfmd_cli.egg-info/entry_points.txt +5 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_cli.egg-info/requires.txt +4 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_cli.egg-info/top_level.txt +1 -0
- pdfmd_cli-3.23.17/pdfmd_unicode/__init__.py +16 -0
- pdfmd_cli-3.23.17/pdfmd_unicode/_catalog.py +549 -0
- pdfmd_cli-3.23.17/pdfmd_unicode/_scripts.py +1009 -0
- pdfmd_cli-3.23.17/pdfmd_unicode/colorfont.py +282 -0
- pdfmd_cli-3.23.17/pdfmd_unicode/emoji.py +38 -0
- pdfmd_cli-3.23.17/pdfmd_unicode/fonts.py +287 -0
- pdfmd_cli-3.23.17/pdfmd_unicode/install.py +215 -0
- pdfmd_cli-3.23.17/pdfmd_unicode/plan.py +696 -0
- pdfmd_cli-3.23.17/pdfmd_unicode/scripts.py +149 -0
- pdfmd_cli-3.23.17/pdfmd_unicode/translit.py +220 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pyproject.toml +11 -2
- pdfmd_cli-3.23.17/tests/test_attach.py +739 -0
- pdfmd_cli-3.23.17/tests/test_cache_location.py +164 -0
- pdfmd_cli-3.23.17/tests/test_config.py +148 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/tests/test_lookup.py +5 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/tests/test_native.py +6 -1
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/tests/test_packaging.py +12 -0
- pdfmd_cli-3.23.17/tests/test_pdf_input.py +143 -0
- pdfmd_cli-3.23.17/tests/test_polish.py +289 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/tests/test_sections.py +5 -0
- pdfmd_cli-3.23.17/tests/test_translit.py +133 -0
- pdfmd_cli-3.23.17/tests/test_unicode.py +819 -0
- pdfmd_cli-3.21.5/pdfmd_cli.egg-info/entry_points.txt +0 -2
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/LICENSE +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_cli.egg-info/dependency_links.txt +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/LICENSE +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/VENDORED.md +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/__init__.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/_kerning_data.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/assets/fonts/DejaVuSans-LICENSE.txt +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/assets/fonts/DejaVuSans.ttf +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/ast.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/cidfont.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/embedded.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/embedded_metrics.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/emoji.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/emoji_font.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/fonts.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/html_filter.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/image_loader.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/layout.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/parser.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/pdf.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/py.typed +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/render.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/truetype.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/pdfmd_inkmd/url_filter.py +0 -0
- {pdfmd_cli-3.21.5 → pdfmd_cli-3.23.17}/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.23.17
|
|
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
|
|
@@ -11,7 +11,7 @@ Classifier: Environment :: Console
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
13
13
|
Classifier: Topic :: Text Processing :: Markup :: LaTeX
|
|
14
|
-
Requires-Python: >=3.
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
17
|
License-File: pdfmd_inkmd/LICENSE
|
|
@@ -23,6 +23,9 @@ Requires-Dist: pymd2pdf<0.7,>=0.6; python_version >= "3.11" and extra == "math"
|
|
|
23
23
|
Requires-Dist: matplotlib; extra == "math"
|
|
24
24
|
Provides-Extra: emoji
|
|
25
25
|
Requires-Dist: inkmd<0.6,>=0.5; extra == "emoji"
|
|
26
|
+
Provides-Extra: translit
|
|
27
|
+
Requires-Dist: pypinyin; extra == "translit"
|
|
28
|
+
Requires-Dist: anyascii; extra == "translit"
|
|
26
29
|
Provides-Extra: pandoc
|
|
27
30
|
Requires-Dist: pypandoc_binary; extra == "pandoc"
|
|
28
31
|
Dynamic: license-file
|
|
@@ -81,7 +84,20 @@ pipx install pdfmd-cli
|
|
|
81
84
|
```
|
|
82
85
|
|
|
83
86
|
That puts a `pdfmd` command on your PATH, with its Python dependencies, in
|
|
84
|
-
its own isolated environment.
|
|
87
|
+
its own isolated environment. The same with uv:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
uv tool install pdfmd-cli # install; update with: uv tool upgrade pdfmd-cli
|
|
91
|
+
uvx --from pdfmd-cli pdfmd file.md # or run once without installing
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
On macOS, Homebrew installs it together with Pandoc and Typst, so nothing else
|
|
95
|
+
is needed for a first PDF:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
brew install aliperdehan/tap/pdfmd
|
|
99
|
+
```
|
|
100
|
+
|
|
85
101
|
To update later, run `pipx upgrade pdfmd-cli`. (The package is named
|
|
86
102
|
`pdfmd-cli` because `pdfmd` on PyPI is an unrelated PDF-to-Markdown tool.
|
|
87
103
|
The command is still `pdfmd`. For the latest unreleased code, use `pipx
|
|
@@ -124,7 +140,7 @@ Office files.
|
|
|
124
140
|
<details>
|
|
125
141
|
<summary>Without pipx</summary>
|
|
126
142
|
|
|
127
|
-
`pdfmd.py` is a single file that needs Python 3.
|
|
143
|
+
`pdfmd.py` is a single file that needs Python 3.9+ (with `pdfmd_inkmd/`
|
|
128
144
|
beside it for the no-Pandoc fallback). It also runs
|
|
129
145
|
directly, and `pyyaml`/`pypdf` are optional (features that need them are
|
|
130
146
|
skipped with a warning):
|
|
@@ -173,8 +189,9 @@ WARN native (inkmd): notes.md: 2 math expression(s) set as plain text (Unicode,
|
|
|
173
189
|
OK notes.md
|
|
174
190
|
```
|
|
175
191
|
|
|
176
|
-
- **inkmd
|
|
177
|
-
|
|
192
|
+
- **[inkmd](https://github.com/eagredev/inkmd)**, written by Dylan Moir (MIT
|
|
193
|
+
licence), is built in (a copy is vendored in `pdfmd_inkmd/`, about 2 MB,
|
|
194
|
+
standard library only, works offline, same input gives the same bytes). It reads
|
|
178
195
|
GitHub-flavoured Markdown: headings, emphasis, lists, task lists, tables,
|
|
179
196
|
code blocks, quotes, links, images, and PNG/JPEG. It cannot typeset math,
|
|
180
197
|
so formulas are set as readable text instead: Greek letters and operators
|
|
@@ -187,8 +204,11 @@ OK notes.md
|
|
|
187
204
|
150 MB, Python 3.11+, installs matplotlib so formulas render offline, centred,
|
|
188
205
|
as real math; the few matplotlib cannot read are set as text like inkmd's).
|
|
189
206
|
Footnotes, bookmarks and syntax-highlighted code come with it.
|
|
190
|
-
- `pdfmd --install emoji` (`pdfmd-cli[emoji]
|
|
191
|
-
|
|
207
|
+
- `pdfmd --install emoji` (about 11 MB; `pdfmd-cli[emoji]` is the pip way for the
|
|
208
|
+
built-in renderer only) puts the colour emoji font in pdfmd's own fonts folder,
|
|
209
|
+
where the built-in renderer and every engine that can draw colour emoji
|
|
210
|
+
(Typst) find it; without it emoji print as `[rocket]`-style labels in the
|
|
211
|
+
built-in renderer.
|
|
192
212
|
- `pdfmd --install full` leaves the fallback behind: it installs **Pandoc** (the
|
|
193
213
|
real binary from PyPI's `pypandoc_binary`, about 35 MB, also `--install pandoc`
|
|
194
214
|
/ `pdfmd-cli[pandoc]`) and **Typst** (Typst's own release from GitHub, about
|
|
@@ -241,6 +261,23 @@ saying what it matched (`pdfmd animp`, `pdfmd glucose`). A name that fits two
|
|
|
241
261
|
documents is an error, never a guess; `--no-auto lookup` switches the guessing
|
|
242
262
|
off. An exact file name always wins.
|
|
243
263
|
|
|
264
|
+
**Names in other scripts.** Russian, Ukrainian, Belarusian and Kazakh Cyrillic are
|
|
265
|
+
always understood. Other scripts are off until you ask, one pack per script, so
|
|
266
|
+
nobody carries tables they don't use: `--translit greek,hangul` (or
|
|
267
|
+
`PDFMD_TRANSLIT=greek,hangul`) makes `pdfmd tyche` find `Τύχη.md` and
|
|
268
|
+
`pdfmd unmyeong` find `운명.md`. Built in: `greek`, `armenian`, `georgian`,
|
|
269
|
+
`hebrew`, `arabic` (consonants only, as the scripts write them), `hangul`
|
|
270
|
+
(Revised Romanization) and `kana` (Hepburn). `han` gives pinyin without tones
|
|
271
|
+
(`pdfmd mingyun` finds `命運.md`) and `other` covers every remaining script;
|
|
272
|
+
they use [pypinyin](https://pypi.org/project/pypinyin/) (MIT) and
|
|
273
|
+
[anyascii](https://pypi.org/project/anyascii/) (ISC), installed with
|
|
274
|
+
`pdfmd --install translit` (`pip install "pdfmd-cli[translit]"`; about 3 MB).
|
|
275
|
+
`--translit all` turns every pack on, `--translit none` even Cyrillic off,
|
|
276
|
+
`--translit list` shows what is ready. These are for *finding* a name: plain
|
|
277
|
+
letters, no tones, vowels left out where the script leaves them out. Names that
|
|
278
|
+
romanize alike (homophones) are listed as ambiguous, never picked between. The
|
|
279
|
+
same spelling rules find a section by its heading (`doc#tyche`).
|
|
280
|
+
|
|
244
281
|
### One section
|
|
245
282
|
|
|
246
283
|
`pdfmd doc#onlyapart` builds just the section whose heading is "Only a Part"
|
|
@@ -337,6 +374,143 @@ pdfmd-options:
|
|
|
337
374
|
html: {self-contained: true, css: style.css}
|
|
338
375
|
```
|
|
339
376
|
|
|
377
|
+
### The PDF carries its own source
|
|
378
|
+
|
|
379
|
+
A PDF can hold the document it was built from, so the file you send is also the
|
|
380
|
+
file you can edit again. Ask for it, on the command line or in the document:
|
|
381
|
+
|
|
382
|
+
```sh
|
|
383
|
+
pdfmd report --attach-source # the source goes into report.pdf as an attachment
|
|
384
|
+
pdfmd report --bundle # ... and the data and files its LaTeX reads
|
|
385
|
+
pdfmd --restore report.pdf # write the folder back into report.restored/
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
```yaml
|
|
389
|
+
pdfmd-options:
|
|
390
|
+
attach-source: true # alias: embed-source
|
|
391
|
+
bundle: true # or `all`: the whole folder, not just what the text points at
|
|
392
|
+
bundle-packages: true # also your own LaTeX packages (see below)
|
|
393
|
+
strip-comments: true # the default for the attached copy; see "Comments"
|
|
394
|
+
attach-bibliography: used # or `all`
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Put these in the shared metadata file and every document that finds it carries
|
|
398
|
+
its source. The attachment is the assembled Markdown with the metadata,
|
|
399
|
+
preamble, Lua filters, bibliography and CSL style folded in (the file
|
|
400
|
+
`--assemble-only --embed-metadata` writes), plus a manifest of the original
|
|
401
|
+
layout, so `--restore` gives back `report.md`, `metadata/`, `parts/` and the rest
|
|
402
|
+
where they were, each as a standalone file (a symlinked metadata file or
|
|
403
|
+
bibliography comes back as a copy). Any PDF viewer lists the attachments, and
|
|
404
|
+
`pdfmd --restore report.pdf --list` shows them and what a rebuild needs. A
|
|
405
|
+
restored folder builds the same document: checked on lab reports with a house
|
|
406
|
+
style, a compound library, a shared bibliography and parts.
|
|
407
|
+
|
|
408
|
+
- **Images come out of the PDF itself.** The PDF holds every picture it drew, so
|
|
409
|
+
a plain attach needs no bundle for them: a JPEG comes back byte for byte, a PNG
|
|
410
|
+
as the same pixels (alpha kept), and an SVG or PDF figure as a vector PDF
|
|
411
|
+
(`fig.svg` becomes `fig.pdf`, and the restored Markdown follows).
|
|
412
|
+
- **`--bundle` is for what the PDF does not draw:** CSV data, LaTeX included
|
|
413
|
+
with `\input`, listings. They are stored as separate attachments (`files/...`),
|
|
414
|
+
found from the text, the preamble and, in turn, from the files found; also
|
|
415
|
+
those only your own TeX tree resolves (`\input{library}` from `texmf-home`).
|
|
416
|
+
`--bundle all` takes the whole folder except output and housekeeping. Over
|
|
417
|
+
100 MB (`bundle-max-mb`) only the source is attached. Data whose file name a
|
|
418
|
+
macro builds cannot be found: use `all`.
|
|
419
|
+
- **Your own LaTeX packages** (a house style in `texmf-home`) are recorded with
|
|
420
|
+
their version, and `--restore` tells you what is missing; `--bundle-packages`
|
|
421
|
+
stores them too (with what they `\input` and the graphics they name).
|
|
422
|
+
The TeX distribution's own packages, fonts and Pandoc are not carried.
|
|
423
|
+
- **Comments.** Notes to yourself do not travel: the attached source loses its
|
|
424
|
+
`<!-- -->` comments, the LaTeX preamble's `%` comments, the text between a
|
|
425
|
+
`.bib`'s entries and a CSL file's XML comments. Choose per kind:
|
|
426
|
+
`strip-comments: [preamble, bibliography]` or `{markdown: false}`
|
|
427
|
+
(`--strip-comments-in`, `--keep-comments-in`). Code blocks, `\verb`, `\url` and
|
|
428
|
+
verbatim environments are never touched, and a `%` that closes a line keeps a
|
|
429
|
+
bare `%`, because it swallows the line break. YAML metadata is merged and
|
|
430
|
+
written again, so its `#` comments are always gone.
|
|
431
|
+
- **Only the bibliography entries you cite** are attached (and what they
|
|
432
|
+
cross-reference), not a shared file of hundreds; `attach-bibliography: all`
|
|
433
|
+
keeps it whole, and `nocite: '@*'` keeps every entry.
|
|
434
|
+
- **It is opt-in, and it is everything you wrote.** An attached source includes
|
|
435
|
+
what the author would not send in an email; check `--list` before sharing.
|
|
436
|
+
- `--restore` never overwrites a file and never writes outside its folder. A
|
|
437
|
+
restored Lua filter is code that pdfmd runs beside the document, so restore
|
|
438
|
+
names it: read it first if the PDF is not from you.
|
|
439
|
+
- `-r/--report` builds attach their chapters too. A section build (`doc#section`)
|
|
440
|
+
attaches nothing.
|
|
441
|
+
|
|
442
|
+
### PDF to Markdown
|
|
443
|
+
|
|
444
|
+
The direction follows the files you give it:
|
|
445
|
+
|
|
446
|
+
```sh
|
|
447
|
+
pdfmd paper.pdf # -> paper.md, beside it
|
|
448
|
+
pdfmd paper.pdf -o notes/p.md # an exact file; -o notes/ puts notes/paper.md
|
|
449
|
+
pdfmd paper.pdf --to txt # plain text
|
|
450
|
+
pdfmd scan.pdf --lang eng+rus --ocr tesseract --export-images
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
A PDF that carries its own pdfmd source (above) is restored instead; `--extract`
|
|
454
|
+
(or naming an output file) reads its pages. Everything else is read by
|
|
455
|
+
[batchocr](https://github.com/aliperdehan/batchocr): the text layer in reading
|
|
456
|
+
order, OCR for scanned pages, headings, lists, tables, running headers removed,
|
|
457
|
+
`<!-- Page N -->` markers (`--no-page-markers`, `--page-breaks`, `--keep-headers`).
|
|
458
|
+
pdfmd only routes: any flag it does not know goes to batchocr unchanged, so the
|
|
459
|
+
options of [M1ck4's pdfmd](https://github.com/M1ck4/pdfmd) (`--ocr`, `--lang`,
|
|
460
|
+
`--export-images`, `--page-breaks`, `--preview-only`, `--stats`, `-q`, `--output`)
|
|
461
|
+
work as they did. Install the reader once:
|
|
462
|
+
|
|
463
|
+
```sh
|
|
464
|
+
pdfmd --install batchocr # pip install batchocr[md] from its GitHub release
|
|
465
|
+
brew install tesseract poppler # for scanned pages (apt: tesseract-ocr poppler-utils)
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
Credits and licences: batchocr's Markdown structure stages are M1ck4's
|
|
469
|
+
(MIT; that project is archived) and are vendored inside batchocr with their
|
|
470
|
+
licence. PyMuPDF, which they use, is AGPL-3.0: it is installed as its own
|
|
471
|
+
package by batchocr's `md` extra and is never part of pdfmd. The command name
|
|
472
|
+
`pdfmd` is also used by that project and by an unrelated PyPI package of the same
|
|
473
|
+
name; this one installs as `pdfmd-cli` (and `pdfmd`), so if two are installed use
|
|
474
|
+
`pdfmd-cli` to be sure which one runs.
|
|
475
|
+
|
|
476
|
+
### Bookmarks, header and footer, linked files
|
|
477
|
+
|
|
478
|
+
Ideas from [mdpdf](https://github.com/normanlorrain/mdpdf) (MIT), done on the
|
|
479
|
+
finished PDF with pypdf, so they work with every engine. All off unless you ask:
|
|
480
|
+
|
|
481
|
+
```sh
|
|
482
|
+
pdfmd report.md --bookmarks # PDF bookmarks from the headings, if the engine made none
|
|
483
|
+
pdfmd report.md --header "{title},,{date}" --footer ",Page {page} of {pages},{header}"
|
|
484
|
+
pdfmd report.md --attach-links # the local files the text links to travel inside the PDF
|
|
485
|
+
pdfmd report.md --pdf-author "A. Writer" --pdf-keywords "kinetics, rate" --paper letter
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
A template is `left,middle,right`; `{page} {pages} {header} {date} {title}` are
|
|
489
|
+
filled in per page (`{header}` is the current top-level heading; write `\,` for a
|
|
490
|
+
comma inside a field). The text is Helvetica, so letters outside Latin-1 become
|
|
491
|
+
their base letter or `?`. `--attach-links` stores each linked file as
|
|
492
|
+
`linked/PATH` and puts a paperclip in the margin beside the link.
|
|
493
|
+
|
|
494
|
+
### Other command names: `mdpdf` and `inkmd`
|
|
495
|
+
|
|
496
|
+
pdfmd also installs `mdpdf` and `inkmd` commands that take those tools' own keys
|
|
497
|
+
and do what they did, with pdfmd behind them:
|
|
498
|
+
|
|
499
|
+
```sh
|
|
500
|
+
mdpdf -o out.pdf -f ",,{page}" -a "Name" -p A4 chapter1.md chapter2.md
|
|
501
|
+
inkmd notes.md -o notes.pdf --page-size a4 --family times
|
|
502
|
+
cat notes.md | inkmd > notes.pdf # standard input and output, like inkmd
|
|
503
|
+
inkmd notes.md -e lualatex # naming another engine uses it instead
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
`mdpdf` turns bookmarks and attached links on and combines several inputs into one
|
|
507
|
+
PDF. `inkmd` is `pdfmd -e inkmd`; like inkmd it writes the PDF to standard output
|
|
508
|
+
when you give `-o -`, or no `-o` while output is piped (at a terminal it writes
|
|
509
|
+
`notes.pdf` beside the file instead). The default page is pdfmd's, not Letter: pass
|
|
510
|
+
`-p letter` / `--page-size letter`. If the original `mdpdf` or `inkmd` package is
|
|
511
|
+
installed too, whichever was installed last owns the command name; both accept the
|
|
512
|
+
original's keys.
|
|
513
|
+
|
|
340
514
|
### Slides
|
|
341
515
|
|
|
342
516
|
```sh
|
|
@@ -436,6 +610,26 @@ PDF and reuses it until the package, the preamble, the engine or the plot's
|
|
|
436
610
|
data file changes. Off by default; `--no-cache` for one build; `pdfmd --clear-cache`
|
|
437
611
|
(or deleting the folder) is always safe.
|
|
438
612
|
|
|
613
|
+
**Where the cache lives.** By default in `~/.cache/pdfmd`, one folder per document.
|
|
614
|
+
Folders get moved (a lab report from Downloads into OneDrive), and a cache keyed by
|
|
615
|
+
the old path would be lost: so each cache folder records which document it is, and a
|
|
616
|
+
document with no cache under its new path takes over the one of the same document
|
|
617
|
+
that has lost its original: the same content (SHA-256), or, if you edited it before
|
|
618
|
+
moving it, the same name in a folder of the same name, when only one fits. A copy
|
|
619
|
+
(the original still there) never takes the original's cache, and plot entries find
|
|
620
|
+
their data files again under the new folders. Or keep the cache with the document:
|
|
621
|
+
|
|
622
|
+
```yaml
|
|
623
|
+
pdfmd-options:
|
|
624
|
+
cache: {aux: true, location: document} # or: --cache-location document
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
puts it in a `.cache/pdfmd` folder beside the document (with a `CACHEDIR.TAG`, so
|
|
628
|
+
backup tools skip it, and a `.gitignore`), which travels with the folder. It is
|
|
629
|
+
yours to choose per document, in the config file for everything, or with
|
|
630
|
+
`--cache-location`. `--clear-cache` clears both places. (The colour-emoji pictures
|
|
631
|
+
LaTeX uses are in the same cache.)
|
|
632
|
+
|
|
439
633
|
### Tables straight from a CSV file
|
|
440
634
|
|
|
441
635
|
```markdown
|
|
@@ -478,7 +672,8 @@ Most of these print an `AUTO` line, and each can be switched off individually.
|
|
|
478
672
|
| `READER` | no YAML front matter | reads the file as GitHub-flavoured Markdown (content-sized table columns, relaxed blank-line rules) |
|
|
479
673
|
| `TITLE` | no front matter, first line is `# Title` | that heading becomes the document title, and the remaining headings move up one level |
|
|
480
674
|
| `MARGIN` | no margin or geometry set anywhere | 1-inch margins instead of LaTeX's wide defaults |
|
|
481
|
-
| `MAINFONT` | no `mainfont:` and no `-f` | STIX Two Text, retried with DejaVu Serif if
|
|
675
|
+
| `MAINFONT` | no `mainfont:` and no `-f` | STIX Two Text (Times New Roman if it isn't installed), or a serif that has the letters when the document is mostly in a script STIX Two Text lacks (Kazakh Cyrillic, say); retried with DejaVu Serif if a glyph is still missing. A font you name is never changed except by `fallback: document` |
|
|
676
|
+
| `UNICODE` | text the main font cannot draw (Arabic, Han, Greek with accents, rare symbols...) | sets each run in an installed font for its script (see *Other scripts*), instead of printing boxes |
|
|
482
677
|
| `MONOFONT` | the document contains code | JetBrains Mono for code (Menlo or another installed monospace font if it isn't installed) |
|
|
483
678
|
| `tablewidth` | a wide pipe table | balances column widths so the table fits the page, and leaves narrow tables at their natural width |
|
|
484
679
|
| `YAML` / `TEX` / `LUA` | project files found | attaches `metadata.yaml`, `preamble.tex`, `<name>.lua` (see below) |
|
|
@@ -506,11 +701,89 @@ file paths are shortened here.)
|
|
|
506
701
|
**When a PDF doesn't look the way the Markdown suggests, run `-v` first.**
|
|
507
702
|
The cause is usually one of these automatic decisions, and `-v` names it.
|
|
508
703
|
|
|
704
|
+
### Other scripts
|
|
705
|
+
|
|
706
|
+
A document that mixes scripts needs more than one font. With lualatex or
|
|
707
|
+
xelatex, `pdfmd` reads the character tables of your installed fonts, finds
|
|
708
|
+
the characters the main font cannot draw and sets each run of them in a font
|
|
709
|
+
that can: Arabic and Hebrew right to left, Chinese/Japanese/Korean in the
|
|
710
|
+
flavour the text (kana, hangul) or `lang:` points to, punctuation and marks in
|
|
711
|
+
the font of the text beside them. Characters that no installed font has are
|
|
712
|
+
named in a warning, never dropped or swapped for something else. `-v` shows
|
|
713
|
+
which font each script got.
|
|
714
|
+
|
|
715
|
+
**How much changes is up to you** (`pdfmd-options: {fallback: MODE}`, `--fallback MODE`,
|
|
716
|
+
or the config file's `options:`):
|
|
717
|
+
|
|
718
|
+
| `fallback:` | What happens to a character the main font lacks |
|
|
719
|
+
|---|---|
|
|
720
|
+
| `word` (default) | the whole word goes in one fallback font that draws all of it, so no word mixes two fonts; your main font stays for every other word, even if the document names `DejaVu Serif` |
|
|
721
|
+
| `char` | just that character is set in another installed font |
|
|
722
|
+
| `document` | the installed font that draws most of the document replaces the main font (the old retry-with-DejaVu idea, chosen by coverage) |
|
|
723
|
+
| `off` (or `false`) | nothing: what Pandoc and TeX do without pdfmd (a missing glyph vanishes or prints a box, and they warn) |
|
|
724
|
+
| `box` | no fallback; each missing character is drawn as a black box, so it cannot be overlooked |
|
|
725
|
+
| `error` | no fallback; the build stops, naming the missing characters |
|
|
726
|
+
|
|
727
|
+
`pdfmd --check-fonts doc.md` shows what would happen without building: the main font (and
|
|
728
|
+
why it was changed, if it was), which scripts get which fallback font, the characters no
|
|
729
|
+
installed font draws and the `--install fonts:...` that would fix it; it exits 1 when
|
|
730
|
+
something can't be drawn.
|
|
731
|
+
|
|
732
|
+
Code is held to the same standard: a character the monofont lacks (an arrow, a CJK
|
|
733
|
+
comment) in inline code or a code block is set in a fallback font under LaTeX (a code
|
|
734
|
+
block that needs one is typeset as plain verbatim, without syntax highlighting), and
|
|
735
|
+
through Typst's `codefont` list or a CSS font stack on Typst and WeasyPrint. Math is
|
|
736
|
+
left to its own font.
|
|
737
|
+
|
|
738
|
+
`missing: warn | box | error` (`--missing`) says what happens to a character that *no* installed
|
|
739
|
+
font draws, after the fallback (`box` and `error` as a fallback mode imply it). `char`,
|
|
740
|
+
`word` and `document` also turn emoji into pictures under LaTeX; `off`, `box` and
|
|
741
|
+
`error` leave them alone.
|
|
742
|
+
|
|
743
|
+
Emoji are set as pictures with lualatex and xelatex (which cannot draw colour
|
|
744
|
+
fonts): each emoji, flag, skin tone, family or keycap is looked up in the colour
|
|
745
|
+
emoji font (`pdfmd --install emoji`, a system Noto Color Emoji, or else Apple Color Emoji on
|
|
746
|
+
a Mac), its picture taken out of the font file and included at the height of the text, in
|
|
747
|
+
inline code and code blocks too. Apple's font is read less completely than Noto's: single
|
|
748
|
+
emoji, skin tones and most joined emoji work, but flags and keycaps, and joined emoji it
|
|
749
|
+
does not list, come out as their first emoji or are reported as undrawable (install Noto
|
|
750
|
+
for those). The pictures
|
|
751
|
+
are kept in pdfmd's cache folder; a `.tex` written with `--to latex` points
|
|
752
|
+
there.
|
|
753
|
+
|
|
754
|
+
The same fallback works with Typst (`-e typst`: `#text(font: ...)` runs, and
|
|
755
|
+
the fonts folder handed to Typst) and WeasyPrint (styled spans). WeasyPrint draws
|
|
756
|
+
Noto Color Emoji's bitmaps badly, so emoji are left to the system's own emoji font
|
|
757
|
+
there; Typst draws them well.
|
|
758
|
+
|
|
759
|
+
**Getting fonts.** Anything installed on the machine is used. For the rest,
|
|
760
|
+
`pdfmd --install fonts` lists what pdfmd can fetch and
|
|
761
|
+
`pdfmd --install fonts:arabic,cjk-sc` (or `fonts:core`, `fonts:scripts`,
|
|
762
|
+
`fonts:all`; also `fonts:ja`, `fonts:kazakh`...) fetches it into pdfmd's own
|
|
763
|
+
folder (`~/.local/share/pdfmd/fonts`, `%LOCALAPPDATA%\pdfmd\fonts`; no admin
|
|
764
|
+
rights, nothing system-wide). Every file is checked against a checksum pinned in
|
|
765
|
+
pdfmd before it is kept, and each package keeps its licence beside it (all SIL OFL,
|
|
766
|
+
except DejaVu's own free licence). The list: STIX Two (pdfmd's default main font),
|
|
767
|
+
JetBrains Mono (its default code font), Noto Serif, Amiri and Noto Naskh Arabic,
|
|
768
|
+
Hebrew, Armenian, Georgian, the Indic and Southeast Asian scripts, Syriac,
|
|
769
|
+
Thaana, Cherokee, Oriya, Mongolian, Coptic, Gothic, Runic, Tifinagh, N'Ko,
|
|
770
|
+
Canadian syllabics, Urdu Nastaliq (used for `lang: ur`), sans-serif Indic faces,
|
|
771
|
+
symbols, Noto Serif for Chinese (simplified/traditional), Japanese and Korean (one
|
|
772
|
+
weight each, bold is synthesised) and the Noto Sans CJK ones (`cjk-sans`), DejaVu,
|
|
773
|
+
and colour emoji. When a document needs a script no installed font has, the warning names
|
|
774
|
+
the package to install. `pdfmd --uninstall fonts:NAME` removes some.
|
|
775
|
+
|
|
776
|
+
It stays out of the way of a document that has set up its own fonts per
|
|
777
|
+
script (`ucharclasses`, `\newfontfamily`, `xeCJK`, `\babelfont`,
|
|
778
|
+
`CJKmainfont`, `mainfontfallback`): `pdfmd-options: {unicode: true}` adds
|
|
779
|
+
pdfmd's anyway, and `--no-auto unicode` turns it off.
|
|
780
|
+
|
|
509
781
|
### Switching defaults off
|
|
510
782
|
|
|
511
783
|
```sh
|
|
512
784
|
pdfmd lecture --no-auto # everything off: close to plain pandoc
|
|
513
|
-
pdfmd lecture --no-auto margin mainfont # only these
|
|
785
|
+
pdfmd lecture --no-auto margin mainfont # only these (kinds: reader title margin mainfont monofont tablewidth
|
|
786
|
+
# unicode lookup yaml tex lua ...; `pdfmd --help` lists them)
|
|
514
787
|
```
|
|
515
788
|
|
|
516
789
|
### Passing options to Pandoc
|
|
@@ -541,6 +814,28 @@ that kind of engine. For example, a document full of chemical structures
|
|
|
541
814
|
can require TeX, and a plain memo can skip the slow LaTeX run. `-e` on the
|
|
542
815
|
command line always wins, and a bare `-e` means "try every engine".
|
|
543
816
|
|
|
817
|
+
### Your own defaults: the config file
|
|
818
|
+
|
|
819
|
+
`pdfmd --init-config` writes a commented `~/.config/pdfmd/config.yaml`
|
|
820
|
+
(`$XDG_CONFIG_HOME`; `%APPDATA%\pdfmd` on Windows), `pdfmd --show-config` says
|
|
821
|
+
where it is and what it sets. Its `options:` block takes the same keys as a
|
|
822
|
+
document's `pdfmd-options:` and applies to every document, below anything the
|
|
823
|
+
document or its metadata files say (the command line beats all of them);
|
|
824
|
+
`translit:` is the romanization packs of the name lookup. `PDFMD_CONFIG=other.yaml`
|
|
825
|
+
uses another file, `PDFMD_CONFIG=` (empty) none.
|
|
826
|
+
|
|
827
|
+
```yaml
|
|
828
|
+
translit: [greek, hangul]
|
|
829
|
+
options:
|
|
830
|
+
fallback: word
|
|
831
|
+
pdf-engine: lualatex
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
The decisions pdfmd remembers for you (the Lua filters it trusts, an offer you
|
|
835
|
+
dismissed) live in the same folder, not in `~/.cache/pdfmd`, so cleaning the cache
|
|
836
|
+
(`--clear-cache`) cannot lose them; files from an older version are moved there
|
|
837
|
+
the first time they are needed.
|
|
838
|
+
|
|
544
839
|
## Project files
|
|
545
840
|
|
|
546
841
|
`pdfmd` looks next to the document, and in a `metadata/` folder beside it,
|