mirror of
https://github.com/getgrav/grav.git
synced 2026-05-08 23:45:36 +02:00
Support page defaults merged with system config - #174
This commit is contained in:
@@ -5,9 +5,9 @@ class Parsedown extends \Parsedown
|
||||
{
|
||||
use ParsedownGravTrait;
|
||||
|
||||
public function __construct($page)
|
||||
public function __construct($page, $defaults)
|
||||
{
|
||||
$this->init($page);
|
||||
$this->init($page, $defaults);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ class ParsedownExtra extends \ParsedownExtra
|
||||
{
|
||||
use ParsedownGravTrait;
|
||||
|
||||
public function __construct($page)
|
||||
public function __construct($page, $defaults)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->init($page);
|
||||
$this->init($page, $defaults);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@ trait ParsedownGravTrait
|
||||
* Initialiazation function to setup key variables needed by the MarkdownGravLinkTrait
|
||||
*
|
||||
* @param $page
|
||||
* @param $defaults
|
||||
*/
|
||||
protected function init($page)
|
||||
protected function init($page, $defaults)
|
||||
{
|
||||
$this->page = $page;
|
||||
$this->pages = self::getGrav()['pages'];
|
||||
@@ -36,7 +37,9 @@ trait ParsedownGravTrait
|
||||
$this->pages_dir = self::getGrav()['locator']->findResource('page://');
|
||||
$this->special_chars = array('>' => 'gt', '<' => 'lt', '"' => 'quot');
|
||||
|
||||
$defaults = self::getGrav()['config']->get('system.pages.markdown');
|
||||
if ($defaults == null) {
|
||||
$defaults = self::getGrav()['config']->get('system.pages.markdown');
|
||||
}
|
||||
|
||||
$this->setBreaksEnabled($defaults['auto_line_breaks']);
|
||||
$this->setUrlsLinked($defaults['auto_url_links']);
|
||||
|
||||
@@ -442,9 +442,9 @@ class Page
|
||||
|
||||
// Initialize the preferred variant of Parsedown
|
||||
if ($defaults['extra']) {
|
||||
$parsedown = new ParsedownExtra($this);
|
||||
$parsedown = new ParsedownExtra($this, $defaults);
|
||||
} else {
|
||||
$parsedown = new Parsedown($this);
|
||||
$parsedown = new Parsedown($this, $defaults);
|
||||
}
|
||||
|
||||
$this->content = $parsedown->text($this->content);
|
||||
|
||||
@@ -337,9 +337,9 @@ class TwigExtension extends \Twig_Extension
|
||||
|
||||
// Initialize the preferred variant of Parsedown
|
||||
if ($defaults['extra']) {
|
||||
$parsedown = new ParsedownExtra($page);
|
||||
$parsedown = new ParsedownExtra($page, $defaults);
|
||||
} else {
|
||||
$parsedown = new Parsedown($page);
|
||||
$parsedown = new Parsedown($page, $defaults);
|
||||
}
|
||||
|
||||
$string = $parsedown->text($string);
|
||||
|
||||
Reference in New Issue
Block a user