Merge branch 'develop' into 1.7

# Conflicts:
#	system/src/Grav/Common/Twig/TwigExtension.php
This commit is contained in:
Andy Miller
2019-08-09 18:29:22 -06:00
3 changed files with 10 additions and 6 deletions

View File

@@ -72,6 +72,7 @@
1. [](#improved)
* Use new `Utils::getSupportedPageTypes()` to enforce `html,htm` at the front of the list [#2531](https://github.com/getgrav/grav/issues/2531)
* Updated vendor libraries
* Markdown filter is now page-aware so that it works with modular references [admin#1731](https://github.com/getgrav/grav-plugin-admin/issues/1731)
1. [](#bugfix)
* Fixed some potential issues when `$grav['user']` is not set
* Fixed error when calling `Media::add($name, null)`

View File

@@ -91,7 +91,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
new TwigFilter('fieldName', [$this, 'fieldNameFilter']),
new TwigFilter('ksort', [$this, 'ksortFilter']),
new TwigFilter('ltrim', [$this, 'ltrimFilter']),
new TwigFilter('markdown', [$this, 'markdownFunction'], ['is_safe' => ['html']]),
new TwigFilter('markdown', [$this, 'markdownFunction'], ['needs_context' => true, 'is_safe' => ['html']]),
new TwigFilter('md5', [$this, 'md5Filter']),
new TwigFilter('base32_encode', [$this, 'base32EncodeFilter']),
new TwigFilter('base32_decode', [$this, 'base32DecodeFilter']),
@@ -623,9 +623,10 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
* @param bool $block Block or Line processing
* @return mixed|string
*/
public function markdownFunction($string, $block = true)
public function markdownFunction($context = false, $string, $block = true)
{
return Utils::processMarkdown($string, $block);
$page = $context['page'] ?? null;
return Utils::processMarkdown($string, $block, $page);
}
/**

View File

@@ -1526,13 +1526,15 @@ abstract class Utils
*
* @param string $string
*
* @param bool $block Block or Line processing
* @param bool $block Block or Line processing
* @param null $page
* @return string
* @throws \Exception
*/
public static function processMarkdown($string, $block = true)
public static function processMarkdown($string, $block = true, $page = null)
{
$grav = Grav::instance();
$page = $grav['page'] ?? null;
$page = $page ?? $grav['page'] ?? null;
$defaults = [
'markdown' => $grav['config']->get('system.pages.markdown', []),
'images' => $grav['config']->get('system.images', [])