pub struct TextSegment {Show 14 fields
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>,
pub list: Option<ListKind>,
pub list_depth: u32,
pub blockquote: BlockquoteKind,
pub links: Vec<LinkRun>,
pub svg: Option<String>,
pub code_indent: bool,
}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.
list: Option<ListKind>For li segments: the parent list type and 1-based index.
list_depth: u32Nesting depth of this list item (0-based).
blockquote: BlockquoteKindWhether this segment is inside a <blockquote>.
links: Vec<LinkRun>Hyperlink destinations within this segment, in chapter-text offsets.
svg: Option<String>Markup for a figure the book draws inline rather than referencing as a
file. src names no archive entry in that case, so the bytes have to
travel with the segment. Serialised with the offset cache rather than
skipped: a skipped field would make every inline diagram render on the
first open of a book and vanish on the second.
code_indent: boolTrue only for an ordinary paragraph whose indent came from a Calibre
code-listing margin (resolved via the IndentMap), i.e. the one case
that should render as code. Table cards and nested lists also set
TextSegment::indent but through other fields, so they default to
false and render as prose. Serde-defaulted so offset caches written
before this field existed decode as false.
Implementations§
Source§impl TextSegment
impl TextSegment
pub fn contains(&self, i: usize) -> bool
Sourcepub fn list_marker(&self) -> Option<String>
pub fn list_marker(&self) -> Option<String>
The bullet or number this item draws, if any.
Nesting depth is not baked in here as leading spaces – it is
carried by TextSegment::indent so the renderer insets the whole
block in real pixels. Padding with spaces would only line up in a
monospace face.
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