kudashevs / laravel-parsedown
A Laravel Parsedown wrapper that converts Mardown text into HTML.
Requires
- php: ^7.4|^8.0
- erusev/parsedown: ^1.7
- erusev/parsedown-extra: ^0.8.1
Requires (Dev)
- orchestra/testbench: ^6.27|^7.0|^8.0|^9.0
- phpunit/phpunit: ^9.5|^10.0|^11.0
This package is auto-updated.
Last update: 2025-02-01 08:47:02 UTC
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:
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.