GithubHelp home page GithubHelp logo

geekwolverine / laravel-etched-blade Goto Github PK

View Code? Open in Web Editor NEW

This project forked from olliecodes/laravel-etched-blade

0.0 0.0 0.0 709 KB

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.

License: MIT License

PHP 80.73% HTML 5.06% Blade 14.22%

laravel-etched-blade's Introduction

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.

laravel-etched-blade's People

Contributors

adevade avatar ollieread avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.