PHP code example of founderplus-labs / epub-markdown

1. Go to this page and download the library: Download founderplus-labs/epub-markdown library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

founderplus-labs / epub-markdown example snippets


use FounderplusLabs\EpubMarkdown\EpubToMarkdown;

$result = (new EpubToMarkdown())->convert('/path/to/book.epub');

$result->markdown;      // the whole book, spine order
$result->title;         // "Buku Uji"
$result->authors;       // ["Penulis Uji"]
$result->language;      // "id"
$result->description;   // blurb, plain text (embedded HTML stripped)
$result->publisher;     // "Penerbit Uji"
$result->subjects;      // ["Bisnis"] — dc:subject tags
$result->identifiers;   // ["uji-1"] — ISBN, UUID, whatever the book declares
$result->chapters;      // Chapter[] — href, title, markdown per spine document
$result->outline;       // [['level' => 1, 'title' => 'Bab Satu'], ...]

$epub = new EpubToMarkdown(
    fn (string $chapterHtml): string => MyHtmlToMarkdown::convert($chapterHtml),
);

use League\HTMLToMarkdown\HtmlConverter;

$league = new HtmlConverter(['strip_tags' => true, 'header_style' => 'atx']);

$result = (new EpubToMarkdown(
    fn (string $html): string => $league->convert($html),
))->convert('/path/to/book.epub');

$this->app->singleton(EpubToMarkdown::class);