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