Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow fenced Markdown style*

This allows an alternative format for specifying Markdown content in your YAML file with out the need to indent each line individually.

Usage is:

content: +++
Markdown *content* here.
+++
  • Loading branch information...
commit 3ebb358d8b6a31b61c695b4b51049c9b1c35e33c 1 parent 0a37683
@kolber authored
Showing with 11 additions and 1 deletion.
  1. +11 −1 app/page-data.inc.php
View
12 app/page-data.inc.php
@@ -198,6 +198,13 @@ static function get_shared_data() {
}
}
+ static function preparse_text($text) {
+ $content = preg_replace_callback('/:\s*(\n)?\+{3,}([\S\s]*?)\+{3,}/', create_function('$match',
+ 'return ": |\n ".preg_replace("/\n/", "\n ", $match[2]);'
+ ), $text);
+ return $content;
+ }
+
static function create_textfile_vars($page, $content = false) {
# store contents of content file (if it exists, otherwise, pass back an empty string)
if ($content) {
@@ -206,7 +213,10 @@ static function create_textfile_vars($page, $content = false) {
$content_file = sprintf('%s/%s', $page->file_path, $page->template_name);
$content_file_path = file_exists($content_file.'.yml') ? $content_file.'.yml' : $content_file.'.txt' ;
if (!file_exists($content_file_path)) return;
- $vars = sfYaml::load($content_file_path);
+ # Correct formatting of fenced content
+ $content = file_get_contents($content_file_path);
+ $content = self::preparse_text($content);
+ $vars = sfYaml::load($content);
}
# include shared variables for each page
Please sign in to comment.
Something went wrong with that request. Please try again.