Hello online demo (primum non nocere)

This commit is contained in:
markseu 2014-08-21 16:50:28 +02:00
parent abc74d73f6
commit b05c9f28ac
4 changed files with 20 additions and 5 deletions

View file

@ -1,4 +1,4 @@
Yellow 0.3.14
Yellow 0.3.15
=============
Yellow is for people who make websites. [Visit website](http://datenstrom.se/yellow).

View file

@ -26,6 +26,7 @@ contentDir = content/
contentHomeDir = home/
contentDefaultFile = page.txt
contentPagination = page
contentRemoveHtml = 0
contentExtension = .txt
configExtension = .ini
errorPageFile = error(.*).txt

View file

@ -34,6 +34,8 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser
$this->yellow = $yellow;
$this->page = $page;
$this->idAttributes = array();
$this->no_markup = (bool)$this->yellow->config->get("contentRemoveHtml");
$this->no_entities = (bool)$this->yellow->config->get("contentRemoveHtml");
parent::__construct();
}
@ -43,12 +45,13 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser
$text = preg_replace("/@pageRead/i", $page->get("pageRead"), $text);
$text = preg_replace("/@pageEdit/i", $page->get("pageEdit"), $text);
$text = preg_replace("/@pageError/i", $page->get("pageError"), $text);
$text = $this->transform($text);
$callback = function($matches) use ($page)
{
$matches[2] = $page->yellow->toolbox->normaliseLocation($matches[2], $page->base, $page->location);
return "<a$matches[1]href=\"$matches[2]\"$matches[3]>";
};
return preg_replace_callback("/<a(.*?)href=\"([^\"]+)\"(.*?)>/i", $callback, $this->transform($text));
return preg_replace_callback("/<a(.*?)href=\"([^\"]+)\"(.*?)>/i", $callback, $text);
}
// Return unique id attribute
@ -68,10 +71,11 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser
function doAutoLinks($text)
{
$text = preg_replace_callback("/<(\w+:[^\'\">\s]+)>/", array(&$this, "_doAutoLinks_url_callback"), $text);
$text = preg_replace_callback("/<(\w+@[\w\-\.]+)>/", array(&$this, "_doAutoLinks_email_callback"), $text);
$text = preg_replace_callback("/<([\w\-\.]+@[\w\-\.]+)>/", array(&$this, "_doAutoLinks_email_callback"), $text);
$text = preg_replace_callback("/\[(\w+)\s+(.*?)\]/", array(&$this, "_doAutoLinks_shortcut_callback"), $text);
$text = preg_replace_callback("/\[\-\-(.*?)\-\-\]/", array(&$this, "_doAutoLinks_comment_callback"), $text);
$text = preg_replace_callback("/((http|https|ftp):\/\/\S+[^\'\"\,\.\;\:\s]+)/", array(&$this, "_doAutoLinks_url_callback"), $text);
$text = preg_replace_callback("/(\w+@[\w\-\.]+\.[\w]{2,4})/", array(&$this, "_doAutoLinks_email_callback"), $text);
$text = preg_replace_callback("/([\w\-\.]+@[\w\-\.]+\.[\w]{2,4})/", array(&$this, "_doAutoLinks_email_callback"), $text);
return $text;
}
@ -83,6 +87,15 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser
if(is_null($output)) $output = $matches[0];
return $this->hashBlock($output);
}
// Handle comments
function _doAutoLinks_comment_callback($matches)
{
$text = $matches[1];
$output = "<!--".htmlspecialchars($text, ENT_NOQUOTES)."-->";
if($text[0] == '-') $output = "";
return $this->hashBlock($output);
}
// Handle fenced code blocks
function _doFencedCodeBlocks_callback($matches)

View file

@ -5,7 +5,7 @@
// Yellow main class
class Yellow
{
const Version = "0.3.14";
const Version = "0.3.15";
var $page; //current page
var $pages; //pages from file system
var $config; //configuration
@ -44,6 +44,7 @@ class Yellow
$this->config->setDefault("contentHomeDir", "home/");
$this->config->setDefault("contentDefaultFile", "page.txt");
$this->config->setDefault("contentPagination", "page");
$this->config->setDefault("contentRemoveHtml", "0");
$this->config->setDefault("contentExtension", ".txt");
$this->config->setDefault("configExtension", ".ini");
$this->config->setDefault("configFile", "config.ini");