mirror of
https://github.com/KnpLabs/KnpMarkdownBundle.git
synced 2024-05-17 21:06:32 +02:00
Revert removing Sundown
This commit is contained in:
parent
83d78eb5c7
commit
b9e547fb67
|
@ -26,6 +26,37 @@ class Configuration implements ConfigurationInterface
|
||||||
->scalarNode('service')->cannotBeEmpty()->defaultValue('markdown.parser.max')->end()
|
->scalarNode('service')->cannotBeEmpty()->defaultValue('markdown.parser.max')->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
->arrayNode('sundown')
|
||||||
|
->addDefaultsIfNotSet()
|
||||||
|
->children()
|
||||||
|
->arrayNode('extensions')
|
||||||
|
->addDefaultsIfNotSet()
|
||||||
|
->children()
|
||||||
|
->booleanNode('fenced_code_blocks')->defaultFalse()->end()
|
||||||
|
->booleanNode('no_intra_emphasis')->defaultFalse()->end()
|
||||||
|
->booleanNode('tables')->defaultFalse()->end()
|
||||||
|
->booleanNode('autolink')->defaultFalse()->end()
|
||||||
|
->booleanNode('strikethrough')->defaultFalse()->end()
|
||||||
|
->booleanNode('lax_html_blocks')->defaultFalse()->end()
|
||||||
|
->booleanNode('space_after_headers')->defaultFalse()->end()
|
||||||
|
->booleanNode('superscript')->defaultFalse()->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
->arrayNode('render_flags')
|
||||||
|
->addDefaultsIfNotSet()
|
||||||
|
->children()
|
||||||
|
->booleanNode('filter_html')->defaultFalse()->end()
|
||||||
|
->booleanNode('no_images')->defaultFalse()->end()
|
||||||
|
->booleanNode('no_links')->defaultFalse()->end()
|
||||||
|
->booleanNode('no_styles')->defaultFalse()->end()
|
||||||
|
->booleanNode('safe_links_only')->defaultFalse()->end()
|
||||||
|
->booleanNode('with_toc_data')->defaultFalse()->end()
|
||||||
|
->booleanNode('hard_wrap')->defaultFalse()->end()
|
||||||
|
->booleanNode('xhtml')->defaultFalse()->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end();
|
->end();
|
||||||
|
|
||||||
|
|
30
Parser/SundownParser.php
Normal file
30
Parser/SundownParser.php
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Knp\Bundle\MarkdownBundle\Parser;
|
||||||
|
|
||||||
|
use Knp\Bundle\MarkdownBundle\MarkdownParserInterface;
|
||||||
|
|
||||||
|
use Sundown\Markdown;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SundownParser
|
||||||
|
*
|
||||||
|
* This class wraps the original Sundown parser to implement the KnpMardownBundle interface
|
||||||
|
*/
|
||||||
|
class SundownParser implements MarkdownParserInterface
|
||||||
|
{
|
||||||
|
private $parser;
|
||||||
|
|
||||||
|
public function __construct(Markdown $parser)
|
||||||
|
{
|
||||||
|
$this->parser = $parser;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function transformMarkdown($text)
|
||||||
|
{
|
||||||
|
return $this->parser->render($text);
|
||||||
|
}
|
||||||
|
}
|
26
Resources/config/sundown.xml
Normal file
26
Resources/config/sundown.xml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" ?>
|
||||||
|
<container xmlns="http://symfony.com/schema/dic/services"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
|
|
||||||
|
<parameters>
|
||||||
|
<parameter key="markdown.parser.sundown.class">Knp\Bundle\MarkdownBundle\Parser\SundownParser</parameter>
|
||||||
|
<parameter key="markdown.sundown.base_parser.class">Sundown\Markdown</parameter>
|
||||||
|
<parameter key="markdown.sundown.renderer.class">Sundown\Render\HTML</parameter>
|
||||||
|
</parameters>
|
||||||
|
|
||||||
|
<services>
|
||||||
|
<service id="markdown.parser.sundown" class="%markdown.parser.sundown.class%" public="false">
|
||||||
|
<argument type="service" id="markdown.sundown.base_parser" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="markdown.sundown.base_parser" public="false" class="%markdown.sundown.base_parser.class%">
|
||||||
|
<argument type="service" id="markdown.sundown.renderer" />
|
||||||
|
<argument>%markdown.sundown.extensions%</argument>
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="markdown.sundown.renderer" public="false" class="%markdown.sundown.renderer.class%">
|
||||||
|
<argument>%markdown.sundown.render_flags%</argument>
|
||||||
|
</service>
|
||||||
|
</services>
|
||||||
|
</container>
|
|
@ -31,7 +31,8 @@
|
||||||
"phpstan/phpstan-symfony": "^1.0"
|
"phpstan/phpstan-symfony": "^1.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/twig-bundle": "to use the Twig markdown filter"
|
"symfony/twig-bundle": "to use the Twig markdown filter",
|
||||||
|
"ext-sundown": "to use optional support for php-sundown extension instead of php implementation"
|
||||||
},
|
},
|
||||||
|
|
||||||
"extra": {
|
"extra": {
|
||||||
|
|
Loading…
Reference in a new issue