Add $singleLine param to Twig markdown parser
This allows you to parse just a single line of Markdown, i.e. the parsed output won't include a HTML paragraph element.
This commit is contained in:
parent
be0812fb55
commit
23000af64e
@ -1651,12 +1651,14 @@ class Pico
|
||||
* @see Pico::getFileContent()
|
||||
*
|
||||
* @param string $markdown Markdown contents of a page
|
||||
* @param bool $singleLine whether to parse just a single line of markup
|
||||
*
|
||||
* @return string parsed contents (HTML)
|
||||
*/
|
||||
public function parseFileContent($markdown)
|
||||
public function parseFileContent($markdown, $singleLine = false)
|
||||
{
|
||||
return $this->getParsedown()->text($markdown);
|
||||
$markdownParser = $this->getParsedown();
|
||||
return !$singleLine ? $markdownParser->text($markdown) : $markdownParser->line($markdown);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,13 +113,14 @@ class PicoTwigExtension extends Twig_Extension
|
||||
*
|
||||
* @param string $markdown markdown to parse
|
||||
* @param array $meta meta data to use for %meta.*% replacement
|
||||
* @param bool $singleLine whether to parse just a single line of markup
|
||||
*
|
||||
* @return string parsed HTML
|
||||
*/
|
||||
public function markdownFilter($markdown, array $meta = array())
|
||||
public function markdownFilter($markdown, array $meta = array(), $singleLine = false)
|
||||
{
|
||||
$markdown = $this->getPico()->substituteFileContent($markdown, $meta);
|
||||
return $this->getPico()->parseFileContent($markdown);
|
||||
return $this->getPico()->parseFileContent($markdown, $singleLine);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user