kudashevs/laravel-parsedown
最新稳定版本:v1.0.0
Composer 安装命令:
composer require kudashevs/laravel-parsedown
包简介
A Laravel Parsedown wrapper that converts Mardown text into HTML.
README 文档
README
This is a Laravel Parsedown wrapper. If you want to know more about Parsedown, check out the official repo.
Installation
You can install the package via composer:
composer require kudashevs/laravel-parsedown
Features
- Configuration File
- Blade Directive
- Helper Function
Configuration
If you don't use auto-discovery, just add a ParsedownServiceProvider to the config/app.php
'providers' => [ Kudashevs\LaravelParsedown\Providers\ParsedownServiceProvider::class, ],
This package uses the ParsedownServiceProvider service provider to create a singleton with a Parsedown instance. This
instance is stored in the container under the parsedown name. To change the behavior of this instance, use the following options:
| Name | Description | Default |
|---|---|---|
enable_extra |
Instantiates ParsedownExtra class instead of Parsedown. | false |
safe_mode |
Processes untrusted user-input. | true |
enable_breaks |
Converts line breaks such as \n into <br /> tags. |
false |
escape_markup |
Escapes HTML in trusted input. Redundant if safe_mode is enabled. |
false |
link_urls |
Automatically converts URLs into anchor tags. | true |
inline |
Tells the parsedown() helper and @parsedown directive to use inline parsing by default. |
false |
You can overwrite these values by publishing the config/parsedown.php file with the following command:
php artisan vendor:publish --provider="Kudashevs\LaravelParsedown\Providers\ParsedownServiceProvider"
Usage
The code below shows how the laravel-parsedown can be used in *.blade.php files:
@parsedown('Hello _Parsedown_!')
...or using the helper instead:
{{ parsedown('Hello _Parsedown_!') }}
These examples are going to convert Markdown into this HTML code:
<p>Hello <em>Parsedown</em>!</p>
If you want to use the inline parsing style, you just need to set the second argument as true:
@parsedown('Hello _Parsedown_!', true)
...or using the helper instead:
{{ parsedown('Hello _Parsedown_!', true) }}
The parsing style examples are going to generate:
Hello <em>Parsedown</em>!
The helper is globally available and can also be used with PHP code throughout your project.
License
The MIT License (MIT). Please see the License file for more information.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-29