From da1e1b8d3babe5e9f2aeeb2b885eeac62a9d6dca Mon Sep 17 00:00:00 2001
From: joyqi <magike.net@gmail.com>
Date: Fri, 27 Oct 2017 00:43:08 +0800
Subject: [PATCH] fix #624

---
 admin/editor-js.php | 9 +++++++--
 var/Markdown.php    | 6 +++---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/admin/editor-js.php b/admin/editor-js.php
index 7e37c901..0ec08207 100644
--- a/admin/editor-js.php
+++ b/admin/editor-js.php
@@ -75,10 +75,15 @@ $(document).ready(function () {
         'pre'           :  'pre|code'
     });
 
+    converter.hook('beforeParseInline', function (html) {
+        return html.replace(/^\s*<!\-\-\s*more\s*\-\->\s*$/, function () {
+            return converter.makeHolder('<!--more-->');
+        });
+    });
+
     // 自动跟随
     converter.hook('makeHtml', function (html) {
-        // convert all comment
-        html = html.replace(/&lt;!--(.+?)--&gt;/g, '<!--$1-->');
+        html = html.replace('<p><!--more--></p>', '<!--more-->');
         
         if (html.indexOf('<!--more-->') > 0) {
             var parts = html.split(/\s*<\!\-\-more\-\->\s*/),
diff --git a/var/Markdown.php b/var/Markdown.php
index 94202797..87d4d762 100644
--- a/var/Markdown.php
+++ b/var/Markdown.php
@@ -28,8 +28,8 @@ class Markdown
             });
 
             $parser->hook('beforeParseInline', function ($html) use ($parser) {
-                return preg_replace_callback("/<!\-\-(.+?)\-\->/s", function ($matches) use ($parser) {
-                    return $parser->makeHolder($matches[0]);
+                return preg_replace_callback("/^\s*<!\-\-\s*more\s*\-\->\s*$/s", function ($matches) use ($parser) {
+                    return $parser->makeHolder('<!--more-->');
                 }, $html);
             });
 
@@ -43,7 +43,7 @@ class Markdown
             ));
         }
 
-        return $parser->makeHtml($text);
+        return str_replace('<p><!--more--></p>', '<!--more-->', $parser->makeHtml($text));
     }
 
     /**