Compare commits

..

1 commit

Author SHA1 Message Date
Oliver Davies 4e893efd97 Replace the markdown parser with CommonMark 2019-11-09 08:54:08 +00:00
4 changed files with 305 additions and 342 deletions

View file

@ -1,3 +1,6 @@
sculpin_content_types:
posts:
enabled: false
parameters:
twig.markdown.parser.class: 'App\Markdown\CommonMarkMarkdownParser'

View file

@ -0,0 +1,22 @@
<?php
namespace App\Markdown;
use League\CommonMark\CommonMarkConverter;
use Opdavies\Sculpin\Bundle\TwigMarkdownBundle\Twig\SculpinTwigMarkdownParserInterface;
class CommonMarkMarkdownParser implements SculpinTwigMarkdownParserInterface
{
/**
* {@inheritdoc}
*/
public function transform($text)
{
$converter = new CommonMarkConverter([
'html_input' => 'strip',
'allow_unsafe_links' => false,
]);
return $converter->convertToHtml($text);
}
}

View file

@ -10,8 +10,9 @@
}
],
"require": {
"sculpin/sculpin": "^3.0",
"opdavies/sculpin-twig-markdown-bundle": "dev-markdown"
"league/commonmark": "^1.1",
"opdavies/sculpin-twig-markdown-bundle": "dev-markdown",
"sculpin/sculpin": "^3.0"
},
"scripts": {
"dev": "composer run-script generate",
@ -26,5 +27,10 @@
"branch-alias": {
"dev-master": "2.1-dev"
}
},
"autoload": {
"psr-4": {
"App\\": "app/src"
}
}
}

612
composer.lock generated

File diff suppressed because it is too large Load diff