scribe/markdown-bundle

此包已被弃用,不再维护。未建议替代包。

集成了 Sundown 解析器的 Bundle

安装: 176

依赖: 1

建议者: 0

安全: 0

星星: 0

观察者: 6

分支: 4

开放问题: 0

类型:symfony-bundle

v0.1.0 2014-09-25 01:29 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:39:58 UTC


README

此 Bundle 允许您轻松地在您的 Symfony 应用程序中使用 markdown 解析器。

查看使用示例: http://www.frenchycode.com/billets/3/voir/test_du_kwattromarkdownbundle 状态

此 Bundle 处于开发阶段。欢迎贡献力量。

Build Status

待办事项

  • 合并参数与 DI 配置
  • 添加所有可能的扩展到 DI 配置
  • 添加标志功能
  • 将配置文件转换为 .xml
  • 使 Twig 扩展使用 Markdown 类
  • 添加一些测试
  • 结构化文档
  • 请求反馈

开源社区

此 Bundle 包装了众多出色开发者的工作

Sundown 基于 Natacha Porté 的原始 Upskirt 解析器,由 Vicent Marti (@tanoku) 添加许多功能,并得到以下作者的贡献

Ben Noordhuis, Bruno Michel, Joseph Koshy, Krzysztof Kowalczyk, Samuel Bronson,
Shuhei Tanuma

php-sundown 是由 [chobie] 制作的 Sundown 项目的 php 封装(https://github.com/chobie/php-sundown

安装

在您的服务器上安装 sundown 和 php-sundown

git clone https://github.com/chobie/php-sundown.git php-sundown -b development
cd php-sundown
# this command will fetch submodule and copy neccesary files to src dir and compile it.
rake submodule compile
sudo rake install

# enable the sundown extension by adding the following line to your php.ini
extension=sundown.so

下载 KwattroMarkdownBundle

将以下内容添加到您的依赖文件中

[KwattroMarkdownBundle]
    git=http://github.com/kwattro/KwattroMarkdownBundle.git
    target=/bundles/Kwattro/MarkdownBundle

并运行以下命令

php bin/vendors install

注册 Bundle

Kwattro 命名空间添加到自动加载器

# /app/autoload.php
$loader->registerNamespaces(array(
//...
'Kwattro' => __DIR__.'/../vendor/bundles',
));

最后,在您的 AppKernel 中注册该 Bundle

# /app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
    //...
    new Kwattro\MarkdownBundle\KwattroMarkdownBundle(),
    );
}

如何使用它

在您的 twig 模板中

您可以在您的 twig 模板中轻松使用 markdown 解析器

{{ body | markdown }}

在您的控制器中使用 kwattro_markdown 服务名称

$markdown = $this->container->get('kwattro_markdown');
$string = $body; //Some string to transform
$output = $markdown->render($string);

您可以根据需要自定义扩展和渲染。第二个数组参数用于标志。

在您的控制器中
$md = $this->container->get('kwattro_markdown');
$string = $body; // some string to transform
$output = $md->render($string, array('autolink' => false), array(), 'xhtml')
在您的模板中
{{ body | markdown( {'autolink': false}, {}, 'html') }}

语法

关于 Markdown 语法 的更多信息,请访问 Markdown 作者的 [网站] (http://daringfireball.net/projects/markdown/)

配置参考

您可以在 config.yml 文件中简单地配置此捆绑包

kwattro_markdown:
    twig_extension: ~ // default is the twig extension provided by the bundle
    renderer : ~ // default `html` You can choose between html | xhtml | base | custom
    render_class: ~ based off the renderer chosen, you have to specify one if "custom" is chosen
    extensions:
        no_intra_emphasis: false
        tables: true
        fenced_code_blocks: true
        autolink: true
        strikethrough: true
        lax_html_blocks: false
        space_after_headers: true
        superscript: false
    flags:
        filter_html: false
        no_images: false
        no_links: false
        no_styles: false
        safe_links_only: false
        with_toc_data: false
        hard_wrap: true
        xhtml: true