Support page defaults merged with system config - #174

This commit is contained in:
Andy Miller
2015-04-20 21:38:26 -06:00
parent 974f9d52a4
commit 030d230312
5 changed files with 13 additions and 10 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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']);

View File

@@ -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);

View File

@@ -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);