christianblos/markdown2html
Composer 安装命令:
composer require christianblos/markdown2html
包简介
Converts markdown files to static html pages
README 文档
README
Converts markdown files to static html pages. See demo (I used it to document another project of mine).
Installation
Use composer to install the latest version: composer require --dev christianblos/markdown2html
Create html via command line
First, you must configure markdown2html by adding a markdown2html.config.php file to the root folder of your repository:
<?php $theme = new Markdown2Html\Theme\DefaultTheme(); $theme->title = 'My Project'; $config = new \Markdown2Html\Config(); $config->src = '/path/to/markdown-files'; $config->dest = '/path/to/destination-folder'; $config->theme = $theme; return $config;
Now you can execute vendor/bin/markdown2html to create the html files in your destination folder
Note: If your config file is not in the root folder of your project, you can pass it as first argument:
vendor/bin/markdown2html /path/to/config.php
Create html via code
Maybe you have your own command line tool and you want to use PHP code directly to generate the html files. This is no problem:
<?php $src = '/path/to/markdown-files'; $dest = '/path/to/destination-folder'; $theme = new Markdown2Html\Theme\DefaultTheme(); $theme->title = 'My Project'; $builder = new Markdown2Html\Builder(); $builder->build($src, $dest, $theme);
Structure of Markdown files
The navigation in the generated html is based on your folder structure. Let's assume you have the following file structure:
markdown
|- 00.Installation.md
|- 01.Configuration.md
|- 02.Usage.md
|- 02.Usage
| |- 00.Via-command--line.md
| |- 01.Via-PHP.md
|
|- index.md
The number prefix (like "01.") indicates the order of navigation items. You can omit it if the order doesn't matter.
All dashes are replaced with spaces ("Via-PHP" → "Via PHP"). If you want to have dashes in the navigation, use 2 or 3 dashes:
- "00.Via-command--line.md" → "Via command-line"
- "00.Via-command---line.md" → "Via command - line"
If there is a file having the same name as a folder (like 02.Usage and 02.Usage.md), it will be the index page of this folder. If you don't have the file, the index will be created automatically and contain a sub navigation.
The content of index.md contains the text of the html index page.
In the example above the generated navigation will look like this:
Installation Configuration Usage Via command-line Via PHP
Default Theme
The DefaultTheme has some additional configurations you can use:
<?php $theme = new Markdown2Html\Theme\DefaultTheme(); // Add additional links to the navigation $theme->naviLinks = [ 'Github' => 'https://github.com/christianblos' ]; // overwrite styles $theme->additionalCss = 'a#header {background-color:red}';
christianblos/markdown2html 适用场景与选型建议
christianblos/markdown2html 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.33k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 christianblos/markdown2html 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 christianblos/markdown2html 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-08