https://github.com/kudashevs/laravel-parsedown
A Laravel Parsedown wrapper that converts Mardown text into HTML.
https://github.com/kudashevs/laravel-parsedown
laravel markdown parsedown
Last synced: about 1 month ago
JSON representation
A Laravel Parsedown wrapper that converts Mardown text into HTML.
- Host: GitHub
- URL: https://github.com/kudashevs/laravel-parsedown
- Owner: kudashevs
- License: mit
- Created: 2024-12-29T18:40:16.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2025-01-01T08:37:25.000Z (6 months ago)
- Last Synced: 2025-03-31T16:14:04.489Z (3 months ago)
- Topics: laravel, markdown, parsedown
- Language: PHP
- Homepage:
- Size: 87.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Parsedown
[](https://packagist.org/packages/kudashevs/laravel-parsedown)
[](https://github.com/kudashevs/laravel-parsedown/actions/workflows/run-tests.yml)
[](LICENSE.md)This is a **Laravel Parsedown** wrapper. If you want to know more about Parsedown, check out the [official repo](https://github.com/erusev/parsedown).
## Installation
You can install the package via composer:
```bash
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`
```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](https://github.com/erusev/parsedown-extra) class instead of Parsedown. | `false` |
| `safe_mode` | Processes untrusted user-input. | `true` |
| `enable_breaks` | Converts line breaks such as `\n` into `
` tags. | `false` |
| `escape_markup` | Escapes **HTML** in trusted input. Redundant if `safe_mode` is enabled. | `false` |
| `link_urls` | Automatically converts **URL**s 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:
```bash
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:
```blade
@parsedown('Hello _Parsedown_!')
```
...or using the helper instead:
```blade
{{ parsedown('Hello _Parsedown_!') }}
```These examples are going to convert Markdown into this HTML code:
```htmlHello Parsedown!
```If you want to use the inline parsing style, you just need to set the second argument as `true`:
```blade
@parsedown('Hello _Parsedown_!', true)
```
...or using the helper instead:
```blade
{{ parsedown('Hello _Parsedown_!', true) }}
```The parsing style examples are going to generate:
```html
Hello Parsedown!
```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](LICENSE.md) for more information.