blok/mushdown

A Mustache + Shortcode + Markdown = Mushdown parser for your modern app

1.0.0 2022-03-31 17:31 UTC

This package is not auto-updated.

Last update: 2024-07-16 03:52:23 UTC


README

Build Status Coverage Status Packagist Packagist Packagist

Mushdown, modern parser for modern app.

Installation

Install via composer

composer require blok/mushdown

Publish Configuration File

php artisan vendor:publish --provider="Blok\Mushdown\ServiceProvider" --tag="config"

Usage

How to register a shortcode ?

The shortcode methode works like Wordpress short code, you have 2 params the attributes and the content.

You can register a shortcode like that :


app('mushdown')->register('quote', function ($attr, $content = null) {
    return '<quote '.Html::attributes($attr).'>' . app('mushdown')->compile($content) . '</quote>';
});

echo mushdown(<<<EOT
# Heading

- list

[quote class="mt-2"]Test quote[/quote]

{{user.name}}

EOT, ['user' => ['name' => 'John']]);

will output :

<h1 id="heading">Heading</h1>
<ul>
<li>list</li>
</ul>
<p><quote  class="mt-2">Test quote</quote></p>
<p>test</p>

Order of processing

The Mushdown parser are in this order so it won't make normaly any issue or overlapse :

  1. Shortcode : In house implementation
  2. Mustache : https://github.com/bobthecow/mustache.php
  3. Markdown : https://github.com/spatie/laravel-markdown

Security

If you discover any security related issues, please email instead of using the issue tracker.

Credits

This package is bootstrapped with the help of blok/laravel-package-generator.