willvincent/laravel-markdown

基于 'SmartyPants' 的排版美化功能的 Markdown

dev-master 2016-06-24 21:07 UTC

This package is auto-updated.

Last update: 2024-09-21 20:36:08 UTC


README

提供 Markdown 解析器外观,可选使用 SmartyPants 对 Laravel 5.x 进行排版美化。

安装

使用 composer 下载此包

composer require willvincent/laravel-markdown

注意: 您可能需要将以下内容添加到您的 composer.json 文件中,以便安装开发包

"minimum-stability": "dev",
"prefer-stable": true

更新您的 config/app.php 文件以引用提供者和外观

'providers' => [
    // ...
    willvincent\LaravelMarkdown\LaravelMarkdownServiceProvider::class,
],
'aliases' => [
    // ...

    'Markdown' => willvincent\LaravelMarkdown\Facades\LaravelMarkdownFacade::class,
],

运行 php artisan vendor:publish 将默认配置文件复制到您的应用的配置目录中;config/markdown.php

使用方法

使用很简单,将您想要解析的 markdown(以及根据您的配置设置可选的排版美化)传递给 Markdown 外观类的 parse() 方法。

// Assuming $text is a variable populated with markdown...
Markdown::parse($text)

大多数人可能会用它来在 blade 模板中显示从数据库加载的数据;

  <div class="parsed-markdown-text">{!! Markdown::parse($text) !!}</div>