Repository navigation
feat: named page templates, print preview and user stylesheet - #157
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #153.
Closes #156.
What changed
Named page templates (#153). A template groups margins, body and monospace typography, line height, heading scale and spacing, colour scheme, header and footer, and a title block built from the document title. Four built-ins ship: Article (today's defaults), Manuscript, Letter and Compact. Custom keeps the granular controls exactly as they were.
The selector lives in Preferences > Export and the choice persists in GSettings (
export-template). The granular rows are insensitive unless Custom is selected, because the template would override them anyway. Page size and orientation stay independent: they describe the paper, not the layout.Print preview (#153). A new "Print Preview…" menu item next to "Export to PDF…" runs the same GtkPrintOperation with
PrintOperationAction::Preview, so the preview is drawn by the export pipeline itself and is WYSIWYG by construction.User stylesheet (#156). A CSS file can be loaded in Preferences > Export and is applied on top of the selected template. It is a mapped subset, not a CSS engine:
@pagemargins, and onbody/html/:root,p,h1-h4,pre/code,blockquote,aandtablethe propertiesfont-family,font-size,line-height,color,background-color,margin-bottomand the custom property--block-spacing. Unknown selectors and properties are ignored with a one-line warning on stderr, never aborting the export. Removing the file restores the template output byte for byte.Notes
src/export_pdf.rsand its pagination rules; the CSS parser is a newsrc/export_css.rswith no GTK in it.Testing
xvfb-run -a make checkgreen: fmt, clippy with-D warnings, and every suite (export_pdf 135, tabs_smoke 165, plus the rest), 0 failures.pdftoppmand asserts the first and third are identical and the second differs.