#[non_exhaustive]pub struct Section {
pub metadata: BlockMetadata,
pub title: Title,
pub level: u8,
pub content: Vec<Block>,
pub location: Location,
}Expand description
A Section represents a section in a document.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.metadata: BlockMetadata§title: Title§level: u8§content: Vec<Block>§location: LocationImplementations§
Source§impl Section
impl Section
Sourcepub fn new(
title: Title,
level: u8,
content: Vec<Block>,
location: Location,
) -> Self
pub fn new( title: Title, level: u8, content: Vec<Block>, location: Location, ) -> Self
Create a new section with the given title, level, content, and location.
Sourcepub fn with_metadata(self, metadata: BlockMetadata) -> Self
pub fn with_metadata(self, metadata: BlockMetadata) -> Self
Set the metadata.
Source§impl Section
impl Section
Sourcepub fn generate_id(metadata: &BlockMetadata, title: &[InlineNode]) -> SafeId
pub fn generate_id(metadata: &BlockMetadata, title: &[InlineNode]) -> SafeId
Generate a section ID based on its title and metadata.
This function checks for explicit IDs in the following order:
metadata.id- from attribute list syntax like[id=foo]metadata.anchors- from anchor syntax like[[foo]]or[#foo]
If no explicit ID is found, it generates one from the title by converting to lowercase, replacing spaces and hyphens with underscores, and removing non-alphanumeric characters.
Trait Implementations§
impl StructuralPartialEq for Section
Auto Trait Implementations§
impl Freeze for Section
impl RefUnwindSafe for Section
impl Send for Section
impl Sync for Section
impl Unpin for Section
impl UnwindSafe for Section
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more