Немного доработано сохранение статей. В маркдаун добалена обработка спецсимволов.

This commit is contained in:
Krivchikov Dmitry 2015-09-11 14:29:58 +03:00
parent afe66030f9
commit 8af9a8b59a
2 changed files with 22 additions and 3 deletions

View File

@ -10,6 +10,7 @@ class Markdown
$string = self::replaceItalic($string); $string = self::replaceItalic($string);
$string = self::replaceUnderline($string); $string = self::replaceUnderline($string);
$string = self::replaceUrls($string); $string = self::replaceUrls($string);
$string = self::replaceChars($string);
return $string; return $string;
} }
@ -61,6 +62,24 @@ class Markdown
return preg_replace($pr, $rep, $string); return preg_replace($pr, $rep, $string);
} }
static private function replaceChars($string)
{
$pr = '((^|\s)-{2}($|\s))';
$rep = '$1$2';
$string = preg_replace($pr, $rep, $string);
$pr = '((^|\s)\((c|с)\)($|\s))';
$rep = '$1©$3';
$string = preg_replace($pr, $rep, $string);
$string = str_replace(
array("\r", '"', '«', '»'),
array('', 'ʺ', 'ʺ', 'ʺ'),
$string);
return $string;
}
static function getClear($string) static function getClear($string)
{ {
// Headers // Headers

View File

@ -75,10 +75,10 @@ class ArticlesController extends Controller
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
$title = $_POST['title']; $title = $_POST['title'];
$text = $_POST['text']; $text = str_replace(array('<','>'), array('&lt;','&gt;'), $_POST['text']);
$html = strip_tags($text); $html = strip_tags($_POST['text']);
$html = str_replace(array('<','>','"',"'",' -- '), array('&lt;','&gt;','&Prime;','&prime;',' &ndash; '), $html); $html = str_replace(array('<','>',"'"), array('&lt;','&gt;','&prime;'), $html);
$html = Markdown::processing($html); $html = Markdown::processing($html);
$html = nl2br($html); $html = nl2br($html);