Skip to main content

Module content

Module content 

Source
Expand description

Epub content build functionality

This module provides functionality for creating EPUB content documents.

§Usage

use lib_epub::{
    builder::content::{Block, BlockBuilder, ContentBuilder},
    types::{BlockType, Footnote},
};

let mut block_builder = BlockBuilder::new(BlockType::Title);
block_builder
    .set_content("This is a title")
    .add_footnote(Footnote {
        locate: 15,
        content: "This is a footnote.".to_string(),
    });
let block = block_builder.try_into()?;

let mut builder = ContentBuilder::new("chapter1", "zh-CN")?;
builder.set_title("My Chapter")
    .add_block(block)?
    .add_text_block("This is my first chapter.", vec![])?;
let _ = builder.make("output.xhtml")?;

§Future Work

  • Support more types of content Block

§Notes

  • Requires content-builder feature to use this module.
  • All resource files (images, audio, video) must exist on the local file system.
  • The builder automatically creates a temporary directory for storing files during construction.

Structs§

BlockBuilder
Block Builder
ContentBuilder
Content Builder

Enums§

Block
Content Block