From d9a3bcc262f892971e397578c58e963ccfc1f717 Mon Sep 17 00:00:00 2001 From: yutent Date: Fri, 28 Apr 2023 10:51:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmarkd=20=E6=B7=B7=E5=90=88htm?= =?UTF-8?q?l=E6=97=B6=E6=AE=B5=E8=90=BD=E8=A7=A3=E6=9E=90=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/markd/core.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/markd/core.js b/src/markd/core.js index dd5aa28..11abde5 100644 --- a/src/markd/core.js +++ b/src/markd/core.js @@ -13,7 +13,6 @@ const TAG_RE = /<([\w\-]+)([\w\W]*?)>/g const ATTR_RE = /\s*?on[a-zA-Z]+="[^"]*?"\s*?/g const CODEBLOCK_RE = /```(.*?)([\w\W]*?)```/g const BLOCK_RE = /<([\w\-]+)([^>]*?)>([\w\W]*?)<\/\1>/g -const IS_DOM_RE = /^<([\w\-]+)[^>]*?>.*?<\/\1>$/ const STYLE_RE = /]*?>([\w\W]*?)<\/style>/g const SINGLE_LINE_HTML_RE = /^\s*?<([\w\-]+)[^>]*?>.*?<\/\1>\s*?$/ const MULTI_LINE_HTML_RE = /^\s*?<\/?[^>]*?>/ @@ -74,10 +73,6 @@ const Helper = { }, isTable(str) { return /^\|.+?\|$/.test(str) - }, - // 是否原生dom节点 - isNativeDom(str) { - return IS_DOM_RE.test(str) } } @@ -293,6 +288,7 @@ class Tool { html += it isTable = !isTable tableAlign = true + isHtmlBlock = false continue } @@ -334,6 +330,7 @@ class Tool { } html += it isCodeBlock = !isCodeBlock + isHtmlBlock = false continue } @@ -382,7 +379,7 @@ class Tool { } isList = false } - + isHtmlBlock = false html += head continue } @@ -451,6 +448,7 @@ class Tool { html += it } + isHtmlBlock = false isParagraph = false isBlockquote = true continue @@ -460,6 +458,7 @@ class Tool { let task = Decoder.task(it) if (task) { html += task + isHtmlBlock = false continue } @@ -473,6 +472,11 @@ class Tool { let level = Math.floor(ltrim / 2) //缩进级别 let tag = listChecked === 1 ? 'ol' : 'ul' + if (isParagraph) { + isParagraph = false + html += '

\n' + } + if (isList) { let _level = listChecked === 1 ? orderListLevel : unorderListLevel @@ -507,6 +511,7 @@ class Tool { } isList = true + isHtmlBlock = false continue } @@ -516,11 +521,6 @@ class Tool { continue } - if (Helper.isNativeDom(it)) { - html += it - continue - } - if (isHtmlBlock || isSingleLineHtml) { if (isParagraph) { isParagraph = false