//! Document-structuring section headings. use super::prelude::*; use super::{FontFamily, TextNode}; /// A section heading. #[derive(Debug, Hash)] pub struct HeadingNode { /// The logical nesting depth of the section, starting from one. In the /// default style, this controls the text size of the heading. pub level: usize, /// The heading's contents. pub body: Template, } #[class] impl HeadingNode { /// The heading's font family. Just the normal text family if `auto`. pub const FAMILY: Leveled> = Leveled::Value(Smart::Auto); /// The color of text in the heading. Just the normal text color if `auto`. pub const FILL: Leveled> = Leveled::Value(Smart::Auto); /// The size of text in the heading. pub const SIZE: Leveled = Leveled::Mapping(|level| { let upscale = (1.6 - 0.1 * level as f64).max(0.75); Relative::new(upscale).into() }); /// Whether text in the heading is strengthend. pub const STRONG: Leveled = Leveled::Value(true); /// Whether text in the heading is emphasized. pub const EMPH: Leveled = Leveled::Value(false); /// Whether the heading is underlined. pub const UNDERLINE: Leveled = Leveled::Value(false); /// The extra padding above the heading. pub const ABOVE: Leveled = Leveled::Value(Length::zero()); /// The extra padding below the heading. pub const BELOW: Leveled = Leveled::Value(Length::zero()); fn construct(_: &mut Vm, args: &mut Args) -> TypResult