Epub Studio

👤 Bingo 📦 v1.0.0 ⭐ 4.1 ⬇️ 793 下載
📄 辦公效率 免費

📖 技能介紹


name: epub-studio description: EPUB電子書生成器。Use when user wants to create professional EPUB ebooks from Markdown, text, or structured content. Supports chapters, TOC, cover image, metadata. 電子書、EPUB製作。 version: 1.0.0 license: MIT-0 metadata: {"openclaw": {"emoji": "📚", "requires": {"bins": ["python3"], "env": []}}} dependencies: "pip install ebooklib"


EPUB Studio

專業EPUB電子書生成器,支援Markdown轉EPUB、多章節、目錄、封面。

Features

7w4.net收錄了海量優質技能外掛。

  • 📚 EPUB格式: 標準EPUB 3.0格式
  • 📑 多章節: 自動生成章節
  • 📋 目錄: 自動生成TOC
  • 🖼️ 封面: 支援封面圖片
  • 📝 Markdown輸入: 從Markdown生成
  • 跨平臺: 支援所有電子書閱讀器

Trigger Conditions

  • "生成電子書" / "Create ebook"
  • "做一本EPUB" / "Make EPUB"
  • "Markdown轉EPUB"
  • "epub-studio"

Python Code

import os
from ebooklib import epub

class EpubGenerator:
    def __init__(self, title, author='Unknown', language='zh'):
        self.book = epub.EpubBook()
        self.book.set_title(title)
        self.book.set_language(language)
        self.book.add_author(author)
        self.chapters = []

    def add_chapter(self, title, content, filename=None):
        """Add a chapter"""
        if filename is None:
            filename = f'chapter_{len(self.chapters)+1}.xhtml'

        chapter = epub.EpubHtml(title=title, file_name=filename)
        chapter.content = f'<h1>{title}</h1>{content}'

        self.book.add_item(chapter)
        self.chapters.append(chapter)
        return chapter

    def add_markdown_chapters(self, markdown_content):
        """Split markdown into chapters"""
        sections = markdown_content.split('\n# ')

        for i, section in enumerate(sections):
            if not section.strip():
                continue

            lines = section.split('\n')
            title = lines[0].replace('#', '').strip()
            content = '<br>'.join(lines[1:])

            self.add_chapter(title, content)

    def add_cover(self, image_path):
        """Add cover image"""
        with open(image_path, 'rb') as f:
            cover_image = f.read()

        self.book.set_cover('cover.jpg', cover_image)

    def set_toc(self):
        """Generate table of contents"""
        self.book.toc = self.chapters

        # Add navigation
        self.book.add_item(epub.EpubNcx())
        self.book.add_item(epub.EpubNav())

    def add_spine(self):
        """Set reading order"""
        self.book.spine = ['nav'] + self.chapters

    def save(self, output_path):
        """Save EPUB file"""
        self.set_toc()
        self.add_spine()

        epub.write_epub(output_path, self.book, {})
        return output_path

# Example
gen = EpubGenerator('My Book', author='Author Name')
gen.add_chapter('Chapter 1', '<p>Content here...</p>')
gen.add_chapter('Chapter 2', '<p>More content...</p>')
gen.save('output.epub')

Usage

User: "幫我把這篇Markdown做成電子書"
Agent: 使用 EpubGenerator 生成EPUB

User: "建立一本3章的電子書"
Agent: 分章生成EPUB

Notes

  • 使用ebooklib庫
  • 支援標準EPUB 3.0格式
  • 相容所有電子書閱讀器
  • 支援中英文

🤖 AI 評測

這個Skill質量中等偏上,做得好的地方是功能明確、文件清晰,能滿足基本的EPUB生成需求。不足之處是實現比較簡單,功能相對單一,缺少詳細的配置選項和錯誤處理,對於複雜文件可能支援不夠完善。適合對EPUB格式要求不高的簡單場景使用。

📊 多維度評分

適應性4
規範性4.1
有效性4
可靠性3.5
可信度5

📁 包含檔案 (3 個)

📄 LICENSE.txt 901 B
📄 SKILL.md 3.3 KB
📄 _meta.json 130 B