修复markd解析器

master
yutent 2023-03-24 11:07:20 +08:00
parent 183beac037
commit b59ee76ab5
1 changed files with 18 additions and 11 deletions

View File

@ -303,6 +303,8 @@ class Tool {
for (let it of this.list) { for (let it of this.list) {
// 非空行 // 非空行
if (it) { if (it) {
emptyLineLength = 0
if (~it.indexOf('<table>') || ~it.indexOf('</table>')) { if (~it.indexOf('<table>') || ~it.indexOf('</table>')) {
html += it html += it
isTable = !isTable isTable = !isTable
@ -527,7 +529,7 @@ class Tool {
// 引用结束 // 引用结束
if (isBlockquote) { if (isBlockquote) {
isBlockquote = false isBlockquote = false
if (emptyLineLength > 0) { if (emptyLineLength > 1) {
emptyLineLength = 0 emptyLineLength = 0
while (blockquoteLevel > 0) { while (blockquoteLevel > 0) {
blockquoteLevel-- blockquoteLevel--
@ -538,6 +540,7 @@ class Tool {
} }
if (isList) { if (isList) {
if (emptyLineLength > 1) {
while (orderListLevel > -1 || unorderListLevel > -1) { while (orderListLevel > -1 || unorderListLevel > -1) {
if (orderListLevel > unorderListLevel) { if (orderListLevel > unorderListLevel) {
html += '</ol>' html += '</ol>'
@ -548,17 +551,21 @@ class Tool {
} }
} }
isList = false isList = false
emptyLineLength = 0
}
continue continue
} }
// //
if (isParagraph) { if (isParagraph) {
if (emptyLineLength > 1) {
isParagraph = false isParagraph = false
html += '</p>' html += '</p>'
} }
} }
} }
} }
}
// 修正内嵌样式 // 修正内嵌样式
html = html.replace(STYLE_RE, (m, code) => { html = html.replace(STYLE_RE, (m, code) => {