armin/md2pdf
Composer 安装命令:
composer require armin/md2pdf
包简介
Converts multiple markdown files to HTML and PDF.
README 文档
README
PHP application to convert multiple markdown files to HTML and PDF.
It's a more simple alternative to e.g. pandoc.
This is a very early prototype! Without any release, yet.
Documentation
Checkout the full Documentation in this repository or checkout the rendered PDF version (TODO).
First steps
Download the latest phar binary or add this package (armin/md2pdf) to your composer.json.
When using Composer to require the package, you can access the binary on CLI using:
vendor/bin/md2pdf
Now, you need to create md2pdf.yaml file in your project's root directory.
Minimum example:
title: Test Document author: Armin Vieweg baseUrl: https://github.com/a-r-m-i-n/md2pdf/blob/master rootPath: . structure: - section: Documentation level: 1 - docs/index.md - docs/configuration.md - section: README Contents level: 1 - README.md output: md2pdf-documentation.pdf
In this file, we define the structure of the HTML/PDF output. We can also separate contents, using sections.
Now, you can simply run:
vendor/bin/md2pdf build
Early version
As already mentioned before, this is a very early prototype. The code needs heavy refactoring, some functionality is not working properly or still missing entirely.
It is planned to implement four modes you can choose from:
- init - to kickstart initial md2pdf.yaml file
- check - for new and missing files in structure
- update - update md2pdf.yaml structure (apply results from check)
- build - create the actual output
Currently, the build mode is the only implemented one.
Features
- Merge configured markdown structure (files) and convert to HTML (using league/commonmark)
- Provide extended anchors (including sanitized filename)
- Replace relative links to documentation by extended anchors (does not work properly, yet)
- Prepend configured baseUrl to relative links to files in repository (which are not part of the configured markdwn structure)
- Provide table of content for every headline (with page numbers, good for printing)
- Provide bookmarks for every headline (good for PDF readers)
- Add custom sections to structure to separate contents
- Level customizable (starts with 1)
- You can also pass additional formatted texts, using the
contentssub-key, which accepts markdown formatted input
- Syntax highlighting for embedded code (configurable, using scrivo/highlight.php)
- Configurable styles
- Manual page-breaks and orientation changes possible (
<!-- PAGEBREAK --> <!-- PAGEBREAK:L --> <!-- PAGEBREAK:P -->) - Output converted markdown contents (via HTML) to PDF (using mpdf/mpdf)
- Phar compiler
- because of filesize reasons, only the TTF fonts "DejaVuSerif" and "DejaVuSans" are included to phar binary
Missing
- Modes: init, check and update
- Refactored analyzing of relative links in markdown content
- PDF setup
- sizes, borders, etc
- path to custom fonts
- ability to also save the HTML file
- configuration to disable bookmarks
- cleanup (remove tmp dir)
- complete documentation
armin/md2pdf 适用场景与选型建议
armin/md2pdf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.68k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2021 年 12 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 armin/md2pdf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 armin/md2pdf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-12-09