Skip to main content

Style

Struct Style 

Source
pub struct Style {
Show 72 fields pub schema_version: u32, pub page_width: f32, pub page_height: f32, pub margin_x: f32, pub margin_y: f32, pub page_layout: PageLayoutStyle, pub pad_to_even: bool, pub pad_to_multiple: u32, pub body_font_size: f32, pub body_line_height: f32, pub paragraph_space_after: f32, pub text_color: ColorRgb, pub text_align: TextAlign, pub link: LinkStyle, pub heading: HeadingStyles, pub heading_numbering: HeadingNumbering, pub list_indent: f32, pub list_item_space_after: f32, pub list_marker_gap: f32, pub list_marker: ListMarkerStyle, pub blockquote_indent: f32, pub blockquote_bar_width: f32, pub blockquote_bar_color: ColorRgb, pub blockquote_text_color: ColorRgb, pub code_font_family: String, pub code_font_size: f32, pub code_padding: f32, pub code_background: ColorRgb, pub code_text_color: ColorRgb, pub code_highlight: CodeHighlightStyle, pub callout_padding: f32, pub callout_accent_width: f32, pub callout_styles: CalloutStyles, pub callout_space_after: f32, pub callout_label_size: f32, pub callout_icon_size: f32, pub callout_icon_gap: f32, pub callout_rule_thickness: f32, pub rule_color: ColorRgb, pub rule_thickness: f32, pub rule_space_around: f32, pub toc: TocStyle, pub lof: ListSectionStyle, pub lot: ListSectionStyle, pub pdf_export: PdfExportProfile, pub page_decoration: PageDecorationStyle, pub caption_position: CaptionPosition, pub caption_color: Option<ColorRgb>, pub figure_caption_prefix: String, pub table_caption_prefix: String, pub caption_separator: String, pub image_title_fallback: bool, pub table_column_sizing: TableColumnSizing, pub table_column_weights: Vec<f32>, pub table_borders: TableBorders, pub table_cell_padding: f32, pub table_border_color: ColorRgb, pub table_border_thickness: f32, pub table_edge_color: Option<ColorRgb>, pub table_edge_thickness: Option<f32>, pub table_header_background: ColorRgb, pub table_header_text_color: ColorRgb, pub table_stripe_color: Option<ColorRgb>, pub table_header_column: bool, pub table_space_after: f32, pub footnote: FootnoteStyle, pub watermark: Option<Watermark>, pub font_paths: Vec<String>, pub body_font_families: Vec<String>, pub hyphenation: HyphenationStyle, pub coverpage: CoverPageStyle, pub frontmatter_tables: BTreeMap<String, FrontmatterTable>,
}

Fields§

§schema_version: u32

Schema-version stamp; reserved for future incompatible bumps.

§page_width: f32§page_height: f32§margin_x: f32§margin_y: f32§page_layout: PageLayoutStyle

Multi-column body layout (1 = single column, the default).

§pad_to_even: bool

When the rendered document ends on an odd page, append one page so the physical total is even. Intended for duplex (double-sided) printing, where each new document should begin on the front of a fresh sheet. The padding page carries the running header / footer (and watermark) like any other page but has no body content, and it is counted in the {total} page-of total. Off by default. Ignored when [pad_to_multiple] is greater than 1.

§pad_to_multiple: u32

Append blank pages (header / footer / watermark only) until the physical page count is a multiple of this value. 0 or 1 leaves the count unchanged. 4 is the booklet / saddle-stitch case (four pages per folded sheet). Counts toward {total}. When set, it supersedes [pad_to_even].

§body_font_size: f32§body_line_height: f32§paragraph_space_after: f32§text_color: ColorRgb§text_align: TextAlign

Horizontal alignment for body prose (paragraphs, list-item and callout bodies). Headings, captions and table cells are unaffected. Defaults to left; justify spreads every line but the last to the column width.

§link: LinkStyle

How [text](url) links are visually distinguished from body text. The PDF link annotation is created regardless; this is purely the visual cue so a reader spots the link before they hover over it.

§heading: HeadingStyles§heading_numbering: HeadingNumbering

Automatic 1 / 1.1 / 1.1.1 section numbering. Off by default.

§list_indent: f32§list_item_space_after: f32§list_marker_gap: f32§list_marker: ListMarkerStyle§blockquote_indent: f32§blockquote_bar_width: f32§blockquote_bar_color: ColorRgb§blockquote_text_color: ColorRgb§code_font_family: String§code_font_size: f32§code_padding: f32§code_background: ColorRgb§code_text_color: ColorRgb§code_highlight: CodeHighlightStyle

Per-token-class palette for the small built-in syntax highlighter. Applies to fenced code blocks whose language attribute is recognised.

§callout_padding: f32§callout_accent_width: f32§callout_styles: CalloutStyles§callout_space_after: f32§callout_label_size: f32

Font size (pt) for a callout’s bold label line.

§callout_icon_size: f32

Square draw size (pt) for a callout’s icon.

§callout_icon_gap: f32

Horizontal gap (pt) between the icon and the label / body column.

§callout_rule_thickness: f32

Stroke thickness (pt) for the rules of a decoration = "rules" callout.

§rule_color: ColorRgb§rule_thickness: f32§rule_space_around: f32§toc: TocStyle§lof: ListSectionStyle§lot: ListSectionStyle§pdf_export: PdfExportProfile§page_decoration: PageDecorationStyle§caption_position: CaptionPosition§caption_color: Option<ColorRgb>

Colour for figure/table caption text. None falls back to blockquote_text_color (the historical default); a per-caption {% caption color="#…" %} overrides both.

§figure_caption_prefix: String

Prefix used for figure caption labels — "<prefix> N" or "<prefix> N: caption". Defaults to “Figure”; common alternates include “Fig.”, “Image”, localised forms, etc.

§table_caption_prefix: String

Prefix for table caption labels. Defaults to “Table”; common alternates include “Tab.”.

§caption_separator: String

Separator between the numbered prefix and the caption text (when present). Defaults to “:”.

§image_title_fallback: bool

When true, an image’s title attribute (from {% media title="…" /%} or markdown ![alt](url "title")) is used as the caption / accessibility text when neither an explicit {% caption %} nor alt is present. Off by default — title is otherwise ignored in the PDF, since it has no natural print rendering.

§table_column_sizing: TableColumnSizing§table_column_weights: Vec<f32>

Explicit relative column widths. When set and the count matches a table’s column count, the table’s inner width is split in these proportions (weights, not absolute units — [1.0, 3.0] makes the second column three times the first) and table_column_sizing is ignored for that table. Ideal for key/value metadata tables where a fixed-width label column reads better than content-based sizing. Empty (the default) leaves every table on automatic sizing.

§table_borders: TableBorders

Which rules the table draws: a full grid (default), only horizontal row separators, or none.

§table_cell_padding: f32§table_border_color: ColorRgb§table_border_thickness: f32§table_edge_color: Option<ColorRgb>

Colour of the table’s outer frame — the top/bottom rules (and the left/right rules in grid mode). Unset means edges match the internal table_border_color; a darker edge gives a booktabs look.

§table_edge_thickness: Option<f32>

Thickness of those outer rules; defaults to table_border_thickness.

§table_header_background: ColorRgb§table_header_text_color: ColorRgb§table_stripe_color: Option<ColorRgb>

Background fill for alternating body rows (zebra striping); applied to every other body row. None (the default) disables it. A table can override it with the {% table stripe="#rrggbb" %} attribute, or stripe="none" to switch striping off for that one table.

§table_header_column: bool

Treat the first column as a header column (row headers): its cells render in the header text style (bold, table_header_text_color) over a table_header_background fill, and are tagged as row headers for accessibility. Off by default; set per table with {% table header_column=true %}. Independent of the header row, so a table can have both.

§table_space_after: f32§footnote: FootnoteStyle§watermark: Option<Watermark>

Optional watermark drawn beneath every page’s body content. Use for letterhead images, “DRAFT” diagonals, confidentiality markings, etc. Tagged as Artifact so screen readers ignore it.

§font_paths: Vec<String>

File paths to additional .ttf/.otf fonts that should be loaded into the font collection before laying out the document. Any family they expose can then be referenced via font_families just like the bundled Noto family. Loaded once at the start of the render — paths are not re-checked.

§body_font_families: Vec<String>

Family names used for body text (in fallback order). Empty list means “use the bundled defaults” (Noto Sans + the multi-script Noto fallbacks). Pass family names registered by your own font_paths to swap in a custom typeface.

§hyphenation: HyphenationStyle§coverpage: CoverPageStyle

Synthesised cover page rendered before any body content. Drawn from frontmatter (title, description, authors, date) plus an optional logo. Source documents stay output-agnostic — all cover-page knobs live here in the style.

§frontmatter_tables: BTreeMap<String, FrontmatterTable>

Tags that stand for a table built from the document’s frontmatter, keyed by tag name. Each {% <name> /%} in the composed document (partials and sections included) becomes a level-2 heading and a table, one row per map in the frontmatter list the entry names. Empty by default: a tag named nowhere here renders as Markdoc renders it, which for a self-closing tag is nothing.

[frontmatter_tables.document-history]
key = "documentHistory"
heading = "Document history"
columns = [
  { field = "version", header = "Version" },
  { field = "date", header = "Date" },
  { field = "description", header = "Description" },
]

Implementations§

Source§

impl Style

Source

pub fn from_toml_str(s: &str) -> Result<Self, Error>

Source

pub fn from_toml_file(path: impl AsRef<Path>) -> Result<Self, StyleLoadError>

Source

pub fn padding_multiple(&self) -> usize

Page-count multiple used for trailing blank pages. pad_to_multiple wins when it is greater than 1; otherwise pad_to_even means 2.

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Style

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Style

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Style
where Style: Default,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

§

impl Forget for Style

§

impl Freeze for Style

§

impl Move for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnsafeUnpin for Style

§

impl UnwindSafe for Style

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Finish for T

Source§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.