vtalbot/markdown

Markdown compiler for Laravel 5

3.0.0 2021-03-01 18:41 UTC

This package is auto-updated.

Last update: 2024-11-29 04:14:16 UTC


README

Installation

For Laravel 4

  1. Run composer require vtalbot/markdown:1.5
  2. Run php artisan config:publish vtalbot/markdown
  3. Then edit config.php in app/config/packages/vtalbot/markdown to your needs.
  4. Add 'VTalbot\Markdown\MarkdownServiceProvider', to providers in app/config/app.php and 'Markdown' => 'VTalbot\Markdown\Facades\Markdown', to aliases in app/config/app.php

For Laravel 5+

  1. Run composer require vtalbot/markdown:2.0
  2. Run php artisan vendor:publish --provider=“VTalbot\Markdown\MarkdownServiceProvider”
  3. Then edit markdown.php in your config directory to your needs.
  4. Add VTalbot\Markdown\MarkdownServiceProvider::class to providers in config/app.php and 'Markdown' => VTalbot\Markdown\Facades\Markdown::class to aliases in config/app.php

Usage

http://domain.name/test.md

If test.md doesn't exists in the public directory, it will search for test.md in app/markdown directory. If found, compile it if needed and return the result.

Markdown::make('file-in-markdown-directory');

Or, you can compile a simple string:

Markdown::string('#test');

To handle markdown file not found:

Markdown::setNotFoundHandler(function($file) { return 'Markdown file not found'; });
Markdown::setNotFoundHandler('MarkdownController@missing');

Configuration

For more information on the Markdown configuration, you may refer to http://michelf.ca/projects/php-markdown/configuration .

Changelog

2.0

  • Add support for Laravel 5

1.5

  • Change deprecated dependency.
  • Add Markdown file not found handler.
  • Add configurations based on the new dependency.
  • Add some tests.