From b59ee76ab53f412a489070d738b7011e809dc3ac Mon Sep 17 00:00:00 2001 From: yutent Date: Fri, 24 Mar 2023 11:07:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmarkd=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/markd/index.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/markd/index.js b/src/markd/index.js index 74be18c..4244507 100644 --- a/src/markd/index.js +++ b/src/markd/index.js @@ -303,6 +303,8 @@ class Tool { for (let it of this.list) { // 非空行 if (it) { + emptyLineLength = 0 + if (~it.indexOf('') || ~it.indexOf('
')) { html += it isTable = !isTable @@ -527,7 +529,7 @@ class Tool { // 引用结束 if (isBlockquote) { isBlockquote = false - if (emptyLineLength > 0) { + if (emptyLineLength > 1) { emptyLineLength = 0 while (blockquoteLevel > 0) { blockquoteLevel-- @@ -538,23 +540,28 @@ class Tool { } if (isList) { - while (orderListLevel > -1 || unorderListLevel > -1) { - if (orderListLevel > unorderListLevel) { - html += '' - orderListLevel-- - } else { - html += '' - unorderListLevel-- + if (emptyLineLength > 1) { + while (orderListLevel > -1 || unorderListLevel > -1) { + if (orderListLevel > unorderListLevel) { + html += '' + orderListLevel-- + } else { + html += '' + unorderListLevel-- + } } + isList = false + emptyLineLength = 0 } - isList = false continue } // if (isParagraph) { - isParagraph = false - html += '

' + if (emptyLineLength > 1) { + isParagraph = false + html += '

' + } } } }