Skip to main content

Section

Struct Section 

Source
pub struct Section {
    pub index: usize,
    pub idref: String,
    pub href: String,
    pub full_path: String,
    pub raw_html: String,
    pub processed_html: String,
    pub plain_text: String,
    pub plain_text_lower: String,
    pub char_count: usize,
    pub viewport_width: Option<f64>,
    pub viewport_height: Option<f64>,
}
Expand description

Loaded and processed EPUB section ready for reading.

Fields§

§index: usize§idref: String§href: String§full_path: String§raw_html: String§processed_html: String§plain_text: String§plain_text_lower: String§char_count: usize§viewport_width: Option<f64>§viewport_height: Option<f64>

Implementations§

Source§

impl Section

Source

pub fn new( index: usize, idref: String, href: String, full_path: String, archive: &EpubArchive, ) -> Result<Self, String>

Create and process a section from archive content using default Base64 inlining.

Source

pub fn new_with_strategy( index: usize, idref: String, href: String, full_path: String, archive: &EpubArchive, _strategy: &AssetDeliveryStrategy, ) -> Result<Self, String>

Create and process a section using a specific asset delivery strategy (Base64 vs Resource Stream).

Source

pub fn detect_language(&self) -> Option<String>

Detects the primary language of this section’s plain text content using whatlang.

Source

pub fn tokenize_tts_words(&self) -> Vec<TtsWordToken>

Tokenizes plain text into word tokens with exact character start/end offsets for SpeechSynthesis TTS synchronization.

Source

pub fn to_tts_annotated_html(&self) -> String

Wraps plain text words in the processed HTML with <span id="tts-w-{index}" class="tts-word"> for live SpeechSynthesis word-by-word visual highlighting.

Source

pub fn strip_script_content(&mut self)

Strip embedded