Skip to main content

Module output_template

Module output_template 

Source
Expand description

Output-path templates for the -o / --output CLI flag.

The model is Ghostscript’s: the path the user supplies is a literal template, and the decision about per-page naming is made from the string alone rather than from the number of pages. A template containing a %d conversion expands once per page; one without it names a single file.

Deciding from the string matters because PostScript page counts are not knowable in advance — pages arrive as showpage executes, so the name of page 1 has to be committed before anyone knows whether a page 2 exists. Ghostscript resolves this by opening the literal path once and streaming every page into it, which silently produces a file holding several concatenated images (measured against gs 10.05.1: three PNG signatures and three IEND chunks in one .png, exit 0, no warning). stet accepts the same templates but raises ExpandError::MultiPageNeedsToken on the second page instead, leaving page 1 on disk intact.

Structs§

OutputTemplate
A parsed -o / --output template.

Enums§

ExpandError
Why a template could not be expanded for a given page.
TemplateError
Why a template could not be parsed.

Functions§

insert_page_number
Insert a -NNN page number before a path’s extension.
split_extension
Split a path into (stem, extension-with-dot) at the final . of the last path component. Returns None when that component has no extension.