소스 검색

Hello online demo (primum non nocere)

markseu 11 년 전
부모
커밋
b05c9f28ac
4개의 변경된 파일20개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 1
      README.md
  2. 1 0
      system/config/config.ini
  3. 16 3
      system/core/core-markdownextra.php
  4. 2 1
      system/core/core.php

+ 1 - 1
README.md

@@ -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).
 

+ 1 - 0
system/config/config.ini

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

+ 16 - 3
system/core/core-markdownextra.php

@@ -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)

+ 2 - 1
system/core/core.php

@@ -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");