mirror of
https://github.com/getgrav/grav.git
synced 2026-02-22 06:28:03 +01:00
Added ability to configure markdown options in configuration and in page
This commit is contained in:
@@ -5,7 +5,6 @@ home:
|
||||
|
||||
pages:
|
||||
theme: antimatter # Default theme (defaults to "antimatter" theme)
|
||||
markdown_extra: false # Enable support for Markdown Extra support (GFM by default)
|
||||
order:
|
||||
by: defaults # Order pages by "default", "alpha" or "date"
|
||||
dir: asc # Default ordering direction, "asc" or "desc"
|
||||
@@ -21,6 +20,14 @@ pages:
|
||||
events:
|
||||
page: true # Enable page level events
|
||||
twig: true # Enable twig level events
|
||||
markdown:
|
||||
extra: false # Enable support for Markdown Extra support (GFM by default)
|
||||
auto_line_breaks: true # Enable automatic line breaks
|
||||
auto_url_links: false # Enable automatic HTML links
|
||||
escape_markup: false # Escape markup tags into entities
|
||||
special_chars: # List of special characters to automatically convert to entities
|
||||
'>': 'gt'
|
||||
'<': 'lt'
|
||||
|
||||
cache:
|
||||
enabled: true # Set to true to enable caching
|
||||
|
||||
@@ -412,12 +412,28 @@ class Page
|
||||
/** @var Config $config */
|
||||
$config = self::$grav['config'];
|
||||
|
||||
// get the appropriate setting for markdown extra
|
||||
if (isset($this->markdown_extra) ? $this->markdown_extra : $config->get('system.pages.markdown_extra')) {
|
||||
$defaults = (array) $config->get('system.pages.markdown');
|
||||
if (isset($this->header()->markdown)) {
|
||||
$defaults = array_merge($defaults, $this->header()->markdown);
|
||||
}
|
||||
|
||||
// pages.markdown_extra is deprecated, but still check it...
|
||||
if (isset($this->markdown_extra) || $config->get('system.pages.markdown_extra') !== null) {
|
||||
$defaults['extra'] = $this->markdown_extra;
|
||||
}
|
||||
|
||||
// Initialize the preferred variant of Parsedown
|
||||
if ($defaults['extra']) {
|
||||
$parsedown = new ParsedownExtra($this);
|
||||
} else {
|
||||
$parsedown = new Parsedown($this);
|
||||
}
|
||||
|
||||
$parsedown->setBreaksEnabled($defaults['auto_line_breaks']);
|
||||
$parsedown->setSpecialChars($defaults['special_chars']);
|
||||
$parsedown->setUrlsLinked($defaults['auto_url_links']);
|
||||
$parsedown->setMarkupEscaped($defaults['escape_markup']);
|
||||
|
||||
$this->content = $parsedown->text($this->content);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user