marcandreappel/bladedown
Composer 安装命令:
composer require marcandreappel/bladedown
包简介
Blade directives for Markdown parsing in Laravel 7+.
README 文档
README
A small and lightweight Laravel 7 package for parsing markdown inside of Blade templates.
Installation
Install it with Composer:
composer require marcandreappel/bladedown
Run the php artisan vendor:publish command to publish the configuration file.
Usage
Blade directive
The markdown parser can be used in Blade templates by using the @markdown directive:
<article>
<h1>{{ $post->title }}</h1>
<section class="content">
@markdown($post->body)
</section>
</article>
A block-style syntax is also available:
@markdown
# Hello world
This *text* will be **parsed** to [HTML](http://laravel.com).
@endmarkdown
Facade
$markdown = "# Hello";
$html = Markdown::parse($markdown); // <h1>Hello</h1>
Helpers
$html = markdown('# Hello'); // <h1>Hello</h1>
$html = markdown_capture(function () {
echo "# Hello";
echo "\n\n";
echo "So **cool**!";
});
// <h1>Hello</h1>
// <p>So <b>cool</b>!</p>
You can also resolve the parser from the service container:
$parser = app('Appel\Bladedown\Parser');
$html = $parser->parse('# Hello'); // <h1>Hello</h1>
Drivers
Bladedown allows you to add custom markdown drivers. In order to use a custom markdown driver, you need to create a class which implements the Appel\Bladedown\Drivers\MarkdownDriver interface.
The interface contains two methods: text and line. text is used to convert a block of markdown to HTML, while line is used to convert a single line.
Bladedown ships with a ParsedownDriver using the Parsedown library by @erusev.
Important notes
This package is incompatible with andreasindal/laravel-markdown, because it is build upon it.
Credits
- Andreas Indal (@andreasindal)
- Mohamed Said (@themsaid)
- Emanuil Rusev (@erusev)
License
See the LICENSE file.
统计信息
- 总下载量: 58
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-22