Skip to main content

plates_render/
lib.rs

1//! The document-to-HTML half of `plates`: what a page *looks like*.
2//!
3//! This crate reads nothing and resolves nothing. It is handed source text and
4//! a description of the site that text belongs to, and it gives back HTML —
5//! which is what lets one rendering run in a command-line build, in a sync
6//! server, and in an edge worker without three implementations quietly
7//! disagreeing about what a site looks like.
8//!
9//! The `plates` crate is the layer above: it walks a [`prov::Workspace`],
10//! decides which documents a site holds and where each one lands, and calls
11//! this.
12//!
13//! A body's grammar is its own — Markdown, Djot or HTML, read off the source
14//! document's extension via [`prov::ContentFormat`] — and all three go through
15//! one parser, `twig`. See [`body`] for why that is the same parser the editor
16//! uses and what changed in the output when it stopped being comrak.
17//!
18//! It must remain portable to `wasm32-unknown-unknown`, which is a constraint
19//! rather than a preference: no host functions, no filesystem, no entropy and
20//! no clock. A caller that has those reads the files and passes the bytes in.
21
22pub mod appearance;
23pub mod attachment;
24pub mod body;
25pub mod dates;
26pub mod frontmatter;
27pub mod headings;
28pub mod html;
29mod links;
30pub mod nav;
31pub mod page;
32pub mod shell;
33#[cfg(feature = "templating")]
34pub mod site;
35#[cfg(feature = "syntax-highlighting")]
36pub mod syntax;
37#[cfg(feature = "templating")]
38pub mod template;
39pub mod types;
40pub mod visibility;
41
42pub use appearance::{
43    ColorPalette, ContentWidth, FaviconAsset, FontFamily, ThemeAppearance, TypographySettings,
44};
45#[cfg(feature = "syntax-highlighting")]
46pub use body::render_body_with;
47pub use body::{preprocess_custom_syntax, render_body};
48pub use headings::{anchor_headings, render_toc};
49pub use html::{
50    Generator, HtmlRenderer, ISLAND_CHILD_SCRIPT, ISLAND_CHILD_SCRIPT_FILENAME, PageContext,
51    SiteStyle,
52};
53pub use links::{percent_decode, root_prefix, transform_links};
54pub use nav::{build_site_nav_tree, forest_roots, nav_for_page, neighbours, reading_order};
55pub use shell::{ShellError, ShellSlots, ShellTemplate};
56#[cfg(feature = "syntax-highlighting")]
57pub use syntax::{CLASS_PREFIX, HIGHLIGHTED_CLASS, Syntaxes, highlight_code_blocks};
58pub use types::{
59    Arrangement, FrameDoc, Grain, Grouping, Heading, LinkEdge, OutlineNode, PageLayout,
60    output_filename, serve_at_dest,
61};