aschmelyun / ibis
Markdown 转 PDF 电子书构建工具
Requires
- illuminate/filesystem: ^7.0|^8.0|^9.0|^10.0
- illuminate/support: ^7.0|^8.0|^9.0|^10.0
- mpdf/mpdf: ^8.2
- psr/log: ^3.0
- spatie/commonmark-highlighter: ^2.1
- symfony/console: ^4.2|^5.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- symfony/var-dumper: ^5.0
This package is auto-updated.
Last update: 2024-08-30 01:39:49 UTC
README
插图由 Eric L. Barnes 和 Caneco 提供,来自 Laravel News ❤️.
这个 PHP 工具可以帮助你用 Markdown 编写电子书。运行 ibis build
,将生成包含以下内容的电子书:
- 封面照片。
- 可点击的自动生成目录。
- 代码语法高亮。
- 提供两种主题。浅色和深色。
Ibis 被用来创建 Laravel Queues in Action,这是我于 2020 年 8 月发布的一本电子书。点击这里获取示例。
安装
请确保你的系统已安装 PHP7.3 或更高版本,并且你的 gd 扩展已在 php.ini 文件中启用。
首先,全局安装 composer 包
composer global require themsaid/ibis
然后,在空目录中运行以下命令
ibis init
这将创建以下文件和目录
- /assets
- /assets/fonts
- /assets/cover.jpg
- /assets/theme-light.html
- /assets/theme-dark.html
- /content
- /ibis.php
你可以通过编辑 /ibis.php
配置文件来配置你的书籍。
编写你的电子书
init
命令将在内容文件夹内创建示例 .md 文件。你可以探索这些文件以了解如何编写你的书籍。此示例内容来自 Laravel Queues in Action。
在内容目录内,你可以编写多个 .md
文件。Ibis 使用标题将书籍分成部分和章节
# Part 1
<h1> tags define the start of a part. A separate PDF page will be generated to print the part title and any content below.
## Chapter 1
<h2> tags define the start of a chapter. A chapter starts on a new page always.
### Starting with Ibis
<h3> tags define different titles inside a chapter.
添加不同类型的引用
可以添加三种不同类型的引用:quote
、warning
和 notice
。
>{quote} This is a quote. >{warning} This is a warning. >{notice} This is a notice.
使用图像
图像可以存储在内容文件夹中,然后这样引入

添加封面图像
要使用封面图像,请在 assets/
目录中添加 cover.jpg
(如果你更喜欢基于 HTML 的封面页面,则添加 cover.html
文件)。如果你不想要封面图像,请删除这些文件。
使用字体
编辑你的 /ibis.php
配置文件来定义要从中加载的字体文件,从 /assets/fonts
目录。之后你可以在你的主题中使用定义的字体(/assets/theme-light.html
& /assets/theme-dark.html
)。
生成 PDF 电子书
ibis build
Ibis 将按字母顺序解析文件,并将 PDF 文件存储在 /export
中。
默认情况下,使用浅色主题生成 PDF,要使用深色主题生成 PDF
ibis build dark
生成示例
ibis sample
ibis sample dark
此命令将使用 ibis build
命令生成的文件来从你的 PDF 电子书中生成示例。你可以通过更新 /ibis.php
文件来配置要包含在示例中的页面。
开发
此项目使用 PHP CS Fixer,其中定义了 .php_cs
中的代码标准。
要审查不符合风格的代码,可以运行 fix 命令作为干运行。运行 composer 脚本如下
composer run csfix-review
要修复源代码,请运行以下 composer 脚本
composer run csfix
致谢
许可证
MIT 许可证(MIT)。请参阅 许可证文件 获取更多信息。