mirror of
https://github.com/KnpLabs/KnpMarkdownBundle.git
synced 2024-06-04 23:12:14 +02:00
bd597e66a1
Fix detection of default parser when none is set Add Flavored preset from KnpBundles.com
25 lines
539 B
PHP
25 lines
539 B
PHP
<?php
|
|
|
|
namespace Knp\Bundle\MarkdownBundle\Parser\Preset;
|
|
|
|
/**
|
|
* Copyrights KnpBundle.com
|
|
*/
|
|
class Flavored extends Max
|
|
{
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function transformMarkdown($text)
|
|
{
|
|
$types = array();
|
|
$markdown = preg_replace_callback("@```[ ]*([^\n]*)(.+?)```@smi", function ($m) use (&$types) {
|
|
$types[] = trim($m[1]);
|
|
|
|
return ' '.str_replace("\n", "\n ", trim($m[2], "\r\n"));
|
|
}, parent::transformMarkdown($text));
|
|
|
|
return $markdown;
|
|
}
|
|
}
|