A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Overview

A Laravel package that uses blade templates to parse and convert markdown to HTML

Packagist Version Packagist PHP Version Support GitHub codecov Build Status

Install

Install via composer.

$ composer require olliecodes/laravel-etched-blade

Once installed you'll want to publish the config.

$ php artisan vendor:publish --provider="\OllieCodes\Etched\EtchedServiceProvider" --tag=config

If you want to modify the default themes you can publish those too.

$ php artisan vendor:publish --provider="\OllieCodes\Etched\EtchedServiceProvider" --tag=views

Requirements

This package requires the following;

  • PHP >= 7.3 (Including 8).
  • illuminate/view >= 8.0 < 9.0 - The view component from Laravel.
  • league/commonmark >= 1.6 < 2.0 - The PHP league commonmark library, used for parsing the Markdown.
  • webuni/front-matter >= 1.2 < 2.0 - The front matter parser.

Usage

To render markdown in your blade files you can either do it inline;

@etched
# I am a heading

This is some content

 - I am a list
   - So am I but more
   - I'm the same
 - I'm less than those two
@endetched

Or by including a markdown file (.md)

@include('markdown.content.article-1')

The above references the file markdown/content/article-1.md, and the file will be rendered by etched the same way that blade files normally are.

Themes

You can control the theme used for the rendered markdown in several ways.

Provide it as an argument on the directive.

@etched('simple')
...
@endetched

As an argument when including.

@include('markdown-file', ['theme' => 'simple'])

Or in the front-matter of the markdown.

---
theme: simple
---

I am some content

If no theme is provided the value of etched.defaults.theme is used instead. If multiple are provided, the value from the front-matter will take precedence.

Advanced

All markdown rendering is handled by the OllieCodes\Etched\Etched::render() method.

You can use this method on an instance of Etched

app(\OllieCodes\Etched\Etched::class)->render($content, $theme);

Or using the facade.

\OllieCodes\Etched\Facades\Etched::render($content, $theme);

The second parameter $theme is optional and will default to the config value etched.defaults.theme. The theme will be overridden by the front-matter value if one is provided in the markdown content.

Comments
  • Remove `resources` from .gitattributes

    Remove `resources` from .gitattributes

    With /resources/ not being downloaded when requiring through Composer, the package won't work because there are no theme files included.

    This maybe closes #9.

    bug 
    opened by adevade 1
  • Package not working before publishing config and views

    Package not working before publishing config and views

    Interesting package! Trying it out on a smaller project. Found some bugs:

    After I required the package and added a @etched block in a view, I got the following error: InvalidArgumentException: No theme found for 'simple'.

    Tried publishing the config file by copying the command from the readme: php artisan vendor:publish --provider="\OllieCodes\Etched\EtchedServiceProvider" --tag=config and got the following error: Unable to locate publishable resources. It worked when I removed the leading slash in the namespace.

    Then I reloaded the page and got another error: InvalidArgumentException: View [themes.simple.blocks.code-indented] not found.

    I couldn't publish the views with or without the leading slash in the namespace.

    I think they are not included in the downloaded package because of /resources/ export-ignore in .gitattributes.


    I'll see if I can submit a PR later. Thanks for you work!

    bug 
    opened by adevade 1
  • Recreate and replace default commonmark Table of Contents extension

    Recreate and replace default commonmark Table of Contents extension

    Subtask of #4

    The Table of Contents extension will require some custom work to use blade files to generate the TOC markup. Sadly the whole extension is marked as final.

    • [ ] Create custom table of contents extension that uses blade files
    • [ ] Add unit tests
    enhancement 
    opened by ollieread 0
  • Add support for commonmark Footnote extension

    Add support for commonmark Footnote extension

    Subtask of #4

    The Footnote extension requires 4 custom renderers, 2 block and 2 inline.

    • [ ] Footnote container block renderer
    • [ ] Footnote block renderer
    • [ ] Footnote ref inline renderer
    • [ ] Footnote backref inline renderer
    • [ ] Add unit tests
    enhancement 
    opened by ollieread 0
  • Add support for commonmark GFM extension

    Add support for commonmark GFM extension

    Subtask of #4

    The Github Flavoured Markdown extension requires a custom inline renderer.

    • [ ] Task list item marker inline renderer
    • [ ] Add unit test for GFM
    enhancement 
    opened by ollieread 0
  • Add support for commonmark Autolink extension

    Add support for commonmark Autolink extension

    Subtask of #4.

    The Autolink extension can be added easily because it requires no new renders, just a test to make sure it's working.

    • [ ] Add unit test for autolinking
    enhancement 
    opened by ollieread 0
Releases(v1.0.4)
Owner
Ollie Codes
Ollie Codes
A package to easily make use of Iconic icons in your Laravel Blade views.

Blade Iconic A package to easily make use of Iconic icons in your Laravel Blade views. For a full list of available icons see the SVG directory. Iconi

Malik Alleyne-Jones 17 Aug 25, 2022
A package to easily make use of Simple Icons in your Laravel Blade views.

Blade Simple Icons A package to easily make use of Simple Icons in your Laravel Blade views. For a full list of available icons see the SVG directory.

UB Labs 12 Jan 17, 2022
A package to easily make use of SVG icons in your Laravel Blade views.

Blade Icons A package to easily make use of SVG icons in your Laravel Blade views. Originally "Blade SVG" by Adam Wathan. Turn... <!-- camera.svg -->

Blade UI Kit 1.7k Jan 2, 2023
A package to easily make use of Iconsax in your Laravel Blade views.

Blade Iconsax A package to easily make use of Iconsax in your Laravel Blade views. This package contains 1.000 icons in 6 diferent styles, a total of

Guilherme Saade 4 Oct 22, 2022
Cagilo - a set of simple components for use in your views Laravel Blade.

Cagilo - a set of simple components for use in your views Laravel Blade. Official Documentation Documentation for Cagilo can be found on its we

Cagilo 151 Dec 6, 2022
Create Laravel views (blade template) using 'php artisan' command-line interface

About LaraBit Have you ever wonder to create Laravel views (Blade Templates) using the same type of artisan commands that you usually use to create ne

Ragib MRB 5 Oct 15, 2021
Use Blade templates without the full Laravel framework

blade Use Laravel Blade templates as a standalone component without the full Laravel framework Full documentation is available at http://duncan3dc.git

Craig Duncan 138 Dec 7, 2022
API Blueprint Renderer for Laravel, customizable via Blade templates

API Blueprint Renderer for Laravel This Laravel package Blueprint Docs renders your API Blueprint. It comes with a standard theme that you can customi

Michael Schmidt-Voigt 225 Sep 16, 2022
A library for using Laravel Blade templates in WordPlate.

A library for using Laravel Blade templates in WordPress/WordPlate. Installation Require this package, with Composer, in the root directory of y

null 28 Nov 28, 2022
Vim syntax highlighting for Blade templates.

vim-blade Vim syntax highlighting for Blade templates (Laravel 4+). This plugin contributes to vim-polyglot language pack. Installation Using vim-plug

Jason Walton 194 Dec 1, 2022
Create inline partials in your Blade templates with ease

Create inline partials in your Blade templates with ease. This package introduces a new @capture directive that allows you to capture small parts of y

Ryan Chandler 27 Dec 8, 2022
Blade Snip allows you to use parts of a blade template multiple times. Basically partials, but inline.

Blade Snip Blade Snip allows you to use parts of a blade template multiple times. Basically partials, but inline: <div class="products"> @snip('pr

Jack Sleight 18 Dec 4, 2022
Laravel Philips Hue package to control your lights with remote support

Laravel Philips Hue ?? Introduction I created this package for my company Ploi (https://ploi.io) to control our office lights. For example, when we re

Dennis Smink 81 Aug 11, 2022
A simple drop-in solution for providing UUID support for the IDs of your Eloquent models.

Introduction A simple drop-in solution for providing UUID support for the IDs of your Eloquent models. Both v1 and v4 IDs are supported out of the box

GoldSpec Digital 501 Jan 4, 2023
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.

Webdevetc BlogEtc - Complete Laravel Blog Package Quickly add a blog with admin panel to your existing Laravel project. It has everything included (ro

WebDevEtc. 227 Dec 25, 2022
Custom Blade components to add sortable/drag-and-drop HTML elements in your apps.

Laravel Blade Sortable Demo Repo Installation You can install the package via composer: composer require asantibanez/laravel-blade-sortable After the

Andrés Santibáñez 370 Dec 23, 2022
Stash view is a composer package for Laravel which caches views using Russian Doll Caching methodology.

Stash View Stash view is a composer package for Laravel which caches views using Russian Doll Caching methodology. What is Russian Doll Caching ? It i

Bhushan Gaikwad 18 Nov 20, 2022
A Laravel package for quickly adding .well-known URLs

A Laravel package for quickly adding .well-known URLs well-known is a Laravel package for quickly adding well-known locations (RFC8615) to a Laravel a

Kim Hallberg 2 Sep 13, 2022
🖖Repository Pattern in Laravel. The package allows to filter by request out-of-the-box, as well as to integrate customized criteria and any kind of filters.

Repository Repository Pattern in Laravel. The package allows to filter by request out-of-the-box, as well as to integrate customized criteria and any

Awes.io 160 Dec 26, 2022