Немного доработано сохранение статей. В маркдаун добалена обработка спецсимволов.
This commit is contained in:
parent
afe66030f9
commit
8af9a8b59a
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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('<','>'), $_POST['text']);
|
||||||
|
|
||||||
$html = strip_tags($text);
|
$html = strip_tags($_POST['text']);
|
||||||
$html = str_replace(array('<','>','"',"'",' -- '), array('<','>','″','′',' – '), $html);
|
$html = str_replace(array('<','>',"'"), array('<','>','′'), $html);
|
||||||
$html = Markdown::processing($html);
|
$html = Markdown::processing($html);
|
||||||
$html = nl2br($html);
|
$html = nl2br($html);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue