#[non_exhaustive]pub struct Section<'a> {
pub metadata: BlockMetadata<'a>,
pub title: Title<'a>,
pub level: u8,
pub content: Vec<Block<'a>>,
pub kind: SectionKind,
pub location: Location,
/* private fields */
}Expand description
A Section represents a section in a document.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.metadata: BlockMetadata<'a>§title: Title<'a>§level: u8§content: Vec<Block<'a>>§kind: SectionKindThe section’s structural category (special-section style, or Normal).
location: LocationImplementations§
Source§impl<'a> Section<'a>
impl<'a> Section<'a>
Sourcepub fn new(
title: Title<'a>,
level: u8,
content: Vec<Block<'a>>,
location: Location,
) -> Self
pub fn new( title: Title<'a>, level: u8, content: Vec<Block<'a>>, location: Location, ) -> Self
Create a new section with the given title, level, content, and location.
Sourcepub fn with_metadata(self, metadata: BlockMetadata<'a>) -> Self
pub fn with_metadata(self, metadata: BlockMetadata<'a>) -> Self
Set the metadata.
Sourcepub fn id(&self) -> Cow<'a, str>
pub fn id(&self) -> Cow<'a, str>
Return the explicit or parser-assigned section ID.
Parsed sections avoid collisions with preceding targets when generating IDs. Caller-created sections use the title-derived ID without collision checks.
Sourcepub fn with_numbering(self, enabled: bool) -> Self
pub fn with_numbering(self, enabled: bool) -> Self
Include or exclude this section from automatic numbering.
Section::new disables numbering. Call
Document::renumber_sections after changing
this policy on a section in a document.
Source§impl<'a> Section<'a>
impl<'a> Section<'a>
Sourcepub fn generate_id_string(
metadata: &BlockMetadata<'a>,
title: &[InlineNode<'a>],
) -> String
pub fn generate_id_string( metadata: &BlockMetadata<'a>, title: &[InlineNode<'a>], ) -> String
Generate a section ID based on its title and metadata, returning a String
directly.
Returns the Display-formatted form (prefixed with _ for generated IDs)
without checking for collisions. Use Section::id for parsed sections.