pdfmd-cli 3.15.1__tar.gz → 3.19.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdfmd-cli
3
- Version: 3.15.1
3
+ Version: 3.19.8
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
@@ -172,6 +172,75 @@ pdfmd lecture --to typst -o lecture.typ
172
172
  pdfmd lecture -o lecture.tex # a complete, compilable .tex, not a fragment
173
173
  ```
174
174
 
175
+ ### Stopping part-way
176
+
177
+ `--stop-at` ends the build after a stage; everything before it runs as normal:
178
+
179
+ ```sh
180
+ pdfmd report --stop-at markdown # report.assembled.md: the parts joined into one file
181
+ pdfmd report --assemble-only # the same, shorter
182
+ pdfmd report --stop-at tex # the standalone .tex a LaTeX engine would get (= --to latex)
183
+ ```
184
+
185
+ The assembled file holds just the document text (and is marked
186
+ `pdfmd-assembled: true`), so pdfmd never joins its parts a second time.
187
+
188
+ By default it holds just the text. `--embed-metadata` also folds in what pdfmd
189
+ finds beside the document (metadata, preamble, Lua filters, and the
190
+ bibliography and CSL files the metadata names), so the file no longer needs
191
+ them beside it. What the text points at otherwise (images, files a preamble
192
+ `\input`s) is not embedded: keep it where the document finds it, relative to
193
+ the assembled file.
194
+
195
+ ```sh
196
+ pdfmd report --assemble-only --embed-metadata # metadata.yaml, preamble.tex, Lua filters, .bib/.csl
197
+ pdfmd report --assemble-only --embed-metadata metadata preamble # only those
198
+ pdfmd report --assemble-only --embed-metadata --lua-mode ref # name the filter instead of copying it
199
+ ```
200
+
201
+ An embedded Lua filter sits in a `{=pdfmd}` block at the end of the file. A
202
+ Lua filter can run any command, so one only runs if this machine's pdfmd
203
+ embedded it (otherwise it is skipped with a warning, unless you pass
204
+ `--trust-embedded`).
205
+
206
+ `--lua-mode apply` runs the filters at assembly time instead, so the text
207
+ already has their effect (approximate: Pandoc re-writes the text, and a filter
208
+ that looks at `FORMAT` is embedded instead). `--unpack` goes the other way:
209
+
210
+ ```sh
211
+ pdfmd report.assembled.md --unpack # filters, preamble and metadata back into report.assembled.unpacked/
212
+ ```
213
+
214
+ `pdfmd` finds `report.assembled.unpacked/` beside `report.assembled.md` by
215
+ itself (its metadata, preambles and Lua filters), and `--unpack --slim` strips
216
+ the unpacked parts out of the assembled file, leaving the lean document plus
217
+ that folder.
218
+
219
+ A document can name its own files and set what to embed, in `pdfmd-options`:
220
+
221
+ ```yaml
222
+ pdfmd-options:
223
+ yaml: [base.yaml] # metadata files (like -y); also `metadata:`, or grouped:
224
+ metadata:
225
+ preamble: my-preamble.tex
226
+ lua-filter: my.lua
227
+ embed: {lua: ref} # what --assemble-only embeds without the flag
228
+ ```
229
+
230
+ Plain HTML output is a fragment. For a finished page, or one file with
231
+ everything (images, CSS) inlined, ask for it, on the command line or in the
232
+ document:
233
+
234
+ ```sh
235
+ pdfmd lecture -o lecture.html --self-contained
236
+ ```
237
+
238
+ ```yaml
239
+ pdfmd-options:
240
+ default-output: html # build to HTML when no format is given
241
+ html: {self-contained: true, css: style.css}
242
+ ```
243
+
175
244
  ### Slides
176
245
 
177
246
  ```sh
@@ -213,6 +282,64 @@ into a single PDF, in the order of each file's `chapter:` front-matter
213
282
  field. See [`examples/book/`](https://github.com/aliperdehan/pdfmd/tree/main/examples/book/). `-i FILE` leaves one file
214
283
  out, and `--exclude-unnumbered` skips files without a `chapter:`.
215
284
 
285
+ ### One long document in several files
286
+
287
+ For an article-style document that has grown too long to edit as one file
288
+ (and unlike `-r`, one that should read as a single document, not a
289
+ sequence of chapters), keep a *scaffold* with the front matter, and the
290
+ text in a `parts/` folder beside it, one file per section, each starting with
291
+ its own heading:
292
+
293
+ ```
294
+ report.md front matter only (title, author, ...)
295
+ parts/10-introduction.md
296
+ parts/20-methods.md
297
+ parts/30-discussion.md
298
+ ```
299
+
300
+ Switch it on once, in a `metadata.yaml` shared by your documents, so the
301
+ content files carry no typesetting:
302
+
303
+ ```yaml
304
+ pdfmd-options:
305
+ parts: auto # a document is a scaffold only if parts/ or sections/ exists
306
+ ```
307
+
308
+ ```console
309
+ $ pdfmd report # the whole document, report.pdf
310
+ $ pdfmd report#methods # just that part, report.methods.pdf
311
+ $ pdfmd report#discussion+appendix # several: always in report order
312
+ $ pdfmd parts/20-methods.md # same as report#methods
313
+ $ pdfmd report --list-parts
314
+ $ pdfmd old-report.md --split new-folder # cut an existing single file into parts
315
+ $ pdfmd old-report.md --split new-folder --split-depth 2 # ...and subsections too
316
+ ```
317
+
318
+ The parts are joined in filename order into one Pandoc run, so the result is
319
+ identical to the same text in a single file: labels, citations and numbering
320
+ work across parts, and paths are written relative to the scaffold's folder
321
+ whichever part they are in. A part rebuilt alone is much faster to compile
322
+ but cannot see the others, so references to them print as `??`. See
323
+ [`examples/parts/`](https://github.com/aliperdehan/pdfmd/tree/main/examples/parts/).
324
+
325
+ #### Faster rebuilds: the cache
326
+
327
+ ```yaml
328
+ pdfmd-options:
329
+ cache: {aux: true} # or: pdfmd report --cache
330
+ ```
331
+
332
+ keeps LaTeX's cross-reference files between builds (in `~/.cache/pdfmd`), so
333
+ an unchanged document is typeset once instead of two or three times, and a
334
+ part built on its own shows the real numbers of the parts left out (taken
335
+ from the last full build) instead of `??`. It never skips a build: Pandoc and
336
+ LaTeX still process the whole document from the current sources and package
337
+ every time, so a change shows in the next build. `cache: {plots: true}` (or
338
+ `--cache-plots`, with nulabreport >= 1.26.0) additionally stores each plot as a
339
+ PDF and reuses it until the package, the preamble, the engine or the plot's
340
+ data file changes. Off by default; `--no-cache` for one build; `pdfmd --clear-cache`
341
+ (or deleting the folder) is always safe.
342
+
216
343
  ### Tables straight from a CSV file
217
344
 
218
345
  ```markdown
@@ -152,6 +152,75 @@ pdfmd lecture --to typst -o lecture.typ
152
152
  pdfmd lecture -o lecture.tex # a complete, compilable .tex, not a fragment
153
153
  ```
154
154
 
155
+ ### Stopping part-way
156
+
157
+ `--stop-at` ends the build after a stage; everything before it runs as normal:
158
+
159
+ ```sh
160
+ pdfmd report --stop-at markdown # report.assembled.md: the parts joined into one file
161
+ pdfmd report --assemble-only # the same, shorter
162
+ pdfmd report --stop-at tex # the standalone .tex a LaTeX engine would get (= --to latex)
163
+ ```
164
+
165
+ The assembled file holds just the document text (and is marked
166
+ `pdfmd-assembled: true`), so pdfmd never joins its parts a second time.
167
+
168
+ By default it holds just the text. `--embed-metadata` also folds in what pdfmd
169
+ finds beside the document (metadata, preamble, Lua filters, and the
170
+ bibliography and CSL files the metadata names), so the file no longer needs
171
+ them beside it. What the text points at otherwise (images, files a preamble
172
+ `\input`s) is not embedded: keep it where the document finds it, relative to
173
+ the assembled file.
174
+
175
+ ```sh
176
+ pdfmd report --assemble-only --embed-metadata # metadata.yaml, preamble.tex, Lua filters, .bib/.csl
177
+ pdfmd report --assemble-only --embed-metadata metadata preamble # only those
178
+ pdfmd report --assemble-only --embed-metadata --lua-mode ref # name the filter instead of copying it
179
+ ```
180
+
181
+ An embedded Lua filter sits in a `{=pdfmd}` block at the end of the file. A
182
+ Lua filter can run any command, so one only runs if this machine's pdfmd
183
+ embedded it (otherwise it is skipped with a warning, unless you pass
184
+ `--trust-embedded`).
185
+
186
+ `--lua-mode apply` runs the filters at assembly time instead, so the text
187
+ already has their effect (approximate: Pandoc re-writes the text, and a filter
188
+ that looks at `FORMAT` is embedded instead). `--unpack` goes the other way:
189
+
190
+ ```sh
191
+ pdfmd report.assembled.md --unpack # filters, preamble and metadata back into report.assembled.unpacked/
192
+ ```
193
+
194
+ `pdfmd` finds `report.assembled.unpacked/` beside `report.assembled.md` by
195
+ itself (its metadata, preambles and Lua filters), and `--unpack --slim` strips
196
+ the unpacked parts out of the assembled file, leaving the lean document plus
197
+ that folder.
198
+
199
+ A document can name its own files and set what to embed, in `pdfmd-options`:
200
+
201
+ ```yaml
202
+ pdfmd-options:
203
+ yaml: [base.yaml] # metadata files (like -y); also `metadata:`, or grouped:
204
+ metadata:
205
+ preamble: my-preamble.tex
206
+ lua-filter: my.lua
207
+ embed: {lua: ref} # what --assemble-only embeds without the flag
208
+ ```
209
+
210
+ Plain HTML output is a fragment. For a finished page, or one file with
211
+ everything (images, CSS) inlined, ask for it, on the command line or in the
212
+ document:
213
+
214
+ ```sh
215
+ pdfmd lecture -o lecture.html --self-contained
216
+ ```
217
+
218
+ ```yaml
219
+ pdfmd-options:
220
+ default-output: html # build to HTML when no format is given
221
+ html: {self-contained: true, css: style.css}
222
+ ```
223
+
155
224
  ### Slides
156
225
 
157
226
  ```sh
@@ -193,6 +262,64 @@ into a single PDF, in the order of each file's `chapter:` front-matter
193
262
  field. See [`examples/book/`](https://github.com/aliperdehan/pdfmd/tree/main/examples/book/). `-i FILE` leaves one file
194
263
  out, and `--exclude-unnumbered` skips files without a `chapter:`.
195
264
 
265
+ ### One long document in several files
266
+
267
+ For an article-style document that has grown too long to edit as one file
268
+ (and unlike `-r`, one that should read as a single document, not a
269
+ sequence of chapters), keep a *scaffold* with the front matter, and the
270
+ text in a `parts/` folder beside it, one file per section, each starting with
271
+ its own heading:
272
+
273
+ ```
274
+ report.md front matter only (title, author, ...)
275
+ parts/10-introduction.md
276
+ parts/20-methods.md
277
+ parts/30-discussion.md
278
+ ```
279
+
280
+ Switch it on once, in a `metadata.yaml` shared by your documents, so the
281
+ content files carry no typesetting:
282
+
283
+ ```yaml
284
+ pdfmd-options:
285
+ parts: auto # a document is a scaffold only if parts/ or sections/ exists
286
+ ```
287
+
288
+ ```console
289
+ $ pdfmd report # the whole document, report.pdf
290
+ $ pdfmd report#methods # just that part, report.methods.pdf
291
+ $ pdfmd report#discussion+appendix # several: always in report order
292
+ $ pdfmd parts/20-methods.md # same as report#methods
293
+ $ pdfmd report --list-parts
294
+ $ pdfmd old-report.md --split new-folder # cut an existing single file into parts
295
+ $ pdfmd old-report.md --split new-folder --split-depth 2 # ...and subsections too
296
+ ```
297
+
298
+ The parts are joined in filename order into one Pandoc run, so the result is
299
+ identical to the same text in a single file: labels, citations and numbering
300
+ work across parts, and paths are written relative to the scaffold's folder
301
+ whichever part they are in. A part rebuilt alone is much faster to compile
302
+ but cannot see the others, so references to them print as `??`. See
303
+ [`examples/parts/`](https://github.com/aliperdehan/pdfmd/tree/main/examples/parts/).
304
+
305
+ #### Faster rebuilds: the cache
306
+
307
+ ```yaml
308
+ pdfmd-options:
309
+ cache: {aux: true} # or: pdfmd report --cache
310
+ ```
311
+
312
+ keeps LaTeX's cross-reference files between builds (in `~/.cache/pdfmd`), so
313
+ an unchanged document is typeset once instead of two or three times, and a
314
+ part built on its own shows the real numbers of the parts left out (taken
315
+ from the last full build) instead of `??`. It never skips a build: Pandoc and
316
+ LaTeX still process the whole document from the current sources and package
317
+ every time, so a change shows in the next build. `cache: {plots: true}` (or
318
+ `--cache-plots`, with nulabreport >= 1.26.0) additionally stores each plot as a
319
+ PDF and reuses it until the package, the preamble, the engine or the plot's
320
+ data file changes. Off by default; `--no-cache` for one build; `pdfmd --clear-cache`
321
+ (or deleting the folder) is always safe.
322
+
196
323
  ### Tables straight from a CSV file
197
324
 
198
325
  ```markdown