From af978767940d8b4c6ab733f5341bd023fca19190 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 20 Jan 2015 10:42:13 -0700 Subject: [PATCH 1/2] some initial refactoring --- system/src/Grav/Common/Page/Page.php | 29 +--------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 84c463f68..04d5c4298 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -348,8 +348,7 @@ class Page $update_cache = false; if ($this->content === false) { - // Process Markdown - $this->content = $this->processMarkdown(); + $this->content = $this->shouldProcess('markdown') ? $this->parseMarkdownContent($this->raw_content) : $this->raw_content; $update_cache = true; } @@ -1592,32 +1591,6 @@ class Page return $file && $file->exists(); } - /** - * Process the Markdown if processing is enabled for it. If not, process as 'raw' which simply strips the - * header YAML from the raw, and sends back the content portion. i.e. the bit below the header. - * - * @return string the content for the page - */ - protected function processMarkdown() - { - // Process Markdown if required - $process_method = $this->shouldProcess('markdown') ? 'parseMarkdownContent' : 'rawContent'; - $content = $this->$process_method($this->raw_content); - - return $content; - } - - /** - * Process the raw content. Basically just strips the headers out and returns the rest. - * - * @param string $content Input raw content - * @return string Output content after headers have been stripped - */ - protected function rawContent($content) - { - return $content; - } - /** * Process the Markdown content. This strips the headers, the process the resulting content as Markdown. * From 0ddd2941e95a5d799013931f1e4a5bfb795f96cf Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 20 Jan 2015 18:08:14 -0700 Subject: [PATCH 2/2] Add event when caching markdown content too --- system/src/Grav/Common/Page/Page.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 04d5c4298..422c0e8cc 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -360,6 +360,7 @@ class Page // Do we want to cache markdown, but process twig in each page? if ($update_cache && $process_twig) { + self::$grav->fireEvent('onPageContentProcessed', new Event(['page' => $this])); $cache->save($cache_id, $this->content); $update_cache = false; }