From 8af9a8b59a9e55fffb66b329df5a2e4ae42b3c55 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Fri, 11 Sep 2015 14:29:58 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=BD=D0=BE=20?= =?UTF-8?q?=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=82=D0=B5=D0=B9.=20=D0=92=20=D0=BC=D0=B0?= =?UTF-8?q?=D1=80=D0=BA=D0=B4=D0=B0=D1=83=D0=BD=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D1=81=D0=BF=D0=B5=D1=86=D1=81=D0=B8=D0=BC?= =?UTF-8?q?=D0=B2=D0=BE=D0=BB=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ground/classes/Markdown.php | 19 +++++++++++++++++++ ground/controllers/ArticlesController.php | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) 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);