pub struct TextSegment {
pub start: usize,
pub end: usize,
pub tag: String,
pub id: Option<String>,
pub src: Option<String>,
pub caption: Option<String>,
pub indent: f32,
pub styles: Vec<StyleRun>,
}Expand description
A run of chapter text belonging to one block element, with its char range.
For <img>/<figure> segments the text range is empty (zero-width marker at
the image’s flow position) and src/caption carry the image data.
Fields§
§start: usizeInclusive start byte/char offset into the chapter text.
end: usizeExclusive end offset.
tag: StringElement tag (e.g. p, h1, li, img, figure).
id: Option<String>The element’s id attribute if any (useful for anchoring).
src: Option<String>src for img/figure (None for text blocks).
caption: Option<String>figcaption text for a figure (None for non-figures).
indent: f32Left indent of the block, in em, resolved from the book’s stylesheet
(see crate::html_text::style) plus any leading spaces the markup
kept. 0 for ordinary prose. Serde-defaulted so offset caches written
before indents existed still deserialize.
styles: Vec<StyleRun>Bold/italic spans within this segment, in chapter-text offsets.
Implementations§
Trait Implementations§
Source§impl Clone for TextSegment
impl Clone for TextSegment
Source§fn clone(&self) -> TextSegment
fn clone(&self) -> TextSegment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more