• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

alsterholm/laravel-markdown: A small, lightweight and easy-to-use Laravel packag ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

alsterholm/laravel-markdown

开源软件地址(OpenSource Url):

https://github.com/alsterholm/laravel-markdown

开源编程语言(OpenSource Language):

PHP 100.0%

开源软件介绍(OpenSource Introduction):

⚠️ Important

This project is no longer maintained, will not received any updates and will not support future versions of Laravel.


Laravel-Markdown

Build Status

A small, lightweight and easy-to-use Laravel package for handling markdown. It comes with a facade, a helper function and a Blade directive to make life easier for you.

Laravel version Laravel-Markdown version
5.8, 6.* 3.1.1
5.7 3.0.1
5.6 3.0
5.5 2.0
5.3, 5.4 1.1
5.2 1.0

Installation

To install it, simply pull it down with Composer. Run the php artisan vendor:publish command to publish the configuration file.

composer require andreasindal/laravel-markdown:"3.0.1"

Laravel 5.5 and above use Package Auto-Discovery, so you do not have to manually add the MarkdownServiceProvider.

Usage

Blade-directive

The markdown parser may be used in your Blade templates by using the @markdown directive.

<article>
    <h1>{{ $post->title }}</h1>

    <section class="content">
        @markdown($post->body)
    </section>
</article>

You can also use a block-style syntax:

@markdown
# Hello world

This *text* will be **parsed** to [HTML](http://laravel.com).
@endmarkdown

Facade

If you registered the Markdown facade as shown above, you can easily parse markdown using it.

$markdown = "# Hello";

$html = Markdown::parse($markdown) // <h1>Hello</h1>

Helper-functions

$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>

Of course, you could also resolve the parser from the service container and use it yourself.

$parser = app('Indal\Markdown\Parser');
$html = $parser->parse('# Hello'); // <h1>Hello</h1>

Drivers (NEW!)

Laravel-Markdown allows you to add custom markdown drivers. In order to use a custom markdown driver, you need to create a class that implements the Indal\Markdown\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.

Laravel-Markdown ships with a ParsedownDriver using the Parsedown-package by @erusev.

Credits

License

Licensed under MIT. For more information, see the LICENSE-file.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap