diff --git a/ground/classes/Markdown.php b/ground/classes/Markdown.php index 8e02d84..35a0924 100644 --- a/ground/classes/Markdown.php +++ b/ground/classes/Markdown.php @@ -10,6 +10,7 @@ class Markdown $string = self::replaceItalic($string); $string = self::replaceUnderline($string); $string = self::replaceUrls($string); + $string = self::replaceChars($string); return $string; } @@ -61,6 +62,24 @@ class Markdown 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) { // Headers diff --git a/ground/controllers/ArticlesController.php b/ground/controllers/ArticlesController.php index 4e6c3b1..c2eb6ca 100644 --- a/ground/controllers/ArticlesController.php +++ b/ground/controllers/ArticlesController.php @@ -75,10 +75,10 @@ class ArticlesController extends Controller $id = (int) $_POST['id']; $title = $_POST['title']; - $text = $_POST['text']; + $text = str_replace(array('<','>'), array('<','>'), $_POST['text']); - $html = strip_tags($text); - $html = str_replace(array('<','>','"',"'",' -- '), array('<','>','″','′',' – '), $html); + $html = strip_tags($_POST['text']); + $html = str_replace(array('<','>',"'"), array('<','>','′'), $html); $html = Markdown::processing($html); $html = nl2br($html);