Skip to main content

cdx_core/presentation/
mod.rs

1//! Presentation layer types.
2//!
3//! Presentation layers define how semantic content is rendered visually.
4//! Codex supports three presentation types:
5//!
6//! - [`Paginated`] - Fixed pages for print/PDF
7//! - [`Continuous`] - Vertical scroll for screens
8//! - [`Responsive`] - Adapts to viewport size
9//!
10//! # Philosophy
11//!
12//! Content is authoritative; presentation is derived. The same content
13//! can have multiple presentation layers for different contexts.
14//!
15//! # Print Features
16//!
17//! For professional print workflows, see the [`print`] module which provides:
18//!
19//! - [`MasterPage`] - Reusable page templates with headers, footers, and backgrounds
20//! - [`PrintSpecification`] - Bleed, crop marks, spot colors, and color space settings
21//! - [`PdfXCompliance`] - PDF/X conformance metadata for prepress workflows
22
23mod continuous;
24mod layout;
25mod notes;
26mod paginated;
27mod precise;
28mod print;
29mod responsive;
30mod style;
31mod toc;
32mod typography;
33
34pub use continuous::{Continuous, Section};
35pub use layout::{ColumnLayout, GridArea, GridLayout};
36pub use notes::{EndnotesConfig, FootnotePosition, FootnoteSeparator, FootnotesConfig};
37pub use paginated::{FlowElement, Margins, PageElement, PageSize, Paginated, Position};
38pub use precise::{
39    FontMetrics, LineInfo, PageRegion, PageTemplate, PreciseLayout, PrecisePage,
40    PrecisePageElement, PrecisePageSize,
41};
42pub use print::{
43    AlternateColor, BleedBox, ColorSpace, CropMarkStyle, MasterElementType, MasterPage,
44    MasterPageElement, MasterPageRegion, OutputIntent, PageBox, PdfXCompliance, PdfXLevel,
45    PlaceholderDefinition, PlaceholderType, PrintSpecification, RegionAlignment, SpotColor,
46    SpotColorType,
47};
48pub use responsive::{Breakpoint, Responsive, ResponsiveDefaults, ResponsiveStyle};
49pub use style::{
50    Color, CssValue, FontWeight, Scale, Style, StyleMap, TextAlign, Transform, TransformOrigin,
51    WritingMode,
52};
53pub use toc::{TocConfig, TocLeaders};
54pub use typography::{
55    BaselineGrid, HyphenationConfig, LineNumbering, LineNumberingRestart, LineNumberingSide,
56    TypographyConfig,
57};
58
59/// Presentation type identifier.
60#[derive(Debug, Clone, Copy, PartialEq, Eq, strum::Display)]
61#[strum(serialize_all = "lowercase")]
62pub enum PresentationType {
63    /// Fixed pages for print/PDF (reactive).
64    Paginated,
65    /// Vertical scroll for screens (reactive).
66    Continuous,
67    /// Adapts to viewport size (reactive).
68    Responsive,
69    /// Exact coordinates for pixel-perfect reproduction.
70    /// Required for FROZEN and PUBLISHED documents.
71    Precise,
72}
73
74impl PresentationType {
75    /// Get the type identifier string.
76    #[must_use]
77    pub const fn as_str(&self) -> &'static str {
78        match self {
79            Self::Paginated => "paginated",
80            Self::Continuous => "continuous",
81            Self::Responsive => "responsive",
82            Self::Precise => "precise",
83        }
84    }
85
86    /// Check if this is a reactive (hint-based) presentation type.
87    #[must_use]
88    pub const fn is_reactive(&self) -> bool {
89        matches!(self, Self::Paginated | Self::Continuous | Self::Responsive)
90    }
91
92    /// Check if this is a precise (coordinate-based) presentation type.
93    #[must_use]
94    pub const fn is_precise(&self) -> bool {
95        matches!(self, Self::Precise)
96    }
97}