Skip to content

cyborg42/epub2mdbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EPUB to MDBook Converter

Crates.io License: MIT

A fast and reliable tool to convert EPUB e-books to MDBook format.

Features

  • 📖 Converts EPUB content (XHTML/HTML) to Markdown
  • 📑 Automatically generates SUMMARY.md from the EPUB table of contents
  • 📝 Creates book.toml with metadata (title, authors, description, language)
  • 🖼️ Preserves images and other resources
  • 🔗 Fixes internal links to point to converted Markdown files

Installation

From crates.io

cargo install epub2mdbook

From source

git clone https://github.com/cyborg42/epub2mdbook.git
cd epub2mdbook
cargo install --path .

Usage

Command Line

# Basic usage - creates a subdirectory named after the book
epub2mdbook book.epub

# Specify output directory
epub2mdbook book.epub --output-dir ./output

# Output directly to the directory without creating a subdirectory
epub2mdbook book.epub --output-dir ./my-book --flat

As a Library

Add to your Cargo.toml:

[dependencies]
epub2mdbook = "0.16"

Then use in your code:

use epub2mdbook::convert_epub_to_mdbook;

fn main() -> Result<(), epub2mdbook::error::Error> {
    // Creates ./output/book_name/ with the converted content
    convert_epub_to_mdbook("book.epub", "./output", true)?;

    // Or output directly to ./my-book/ without subdirectory
    convert_epub_to_mdbook("book.epub", "./my-book", false)?;

    Ok(())
}

Output Structure

output/
└── book_name/
    ├── book.toml
    └── src/
        ├── SUMMARY.md
        ├── chapter1.md
        ├── chapter2.md
        └── images/
            └── cover.png

License

This project is licensed under the MIT License

About

Convert EPUB files to MDBook format

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages