修复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,23 +540,28 @@ class Tool {
} }
if (isList) { if (isList) {
while (orderListLevel > -1 || unorderListLevel > -1) { if (emptyLineLength > 1) {
if (orderListLevel > unorderListLevel) { while (orderListLevel > -1 || unorderListLevel > -1) {
html += '</ol>' if (orderListLevel > unorderListLevel) {
orderListLevel-- html += '</ol>'
} else { orderListLevel--
html += '</ul>' } else {
unorderListLevel-- html += '</ul>'
unorderListLevel--
}
} }
isList = false
emptyLineLength = 0
} }
isList = false
continue continue
} }
// //
if (isParagraph) { if (isParagraph) {
isParagraph = false if (emptyLineLength > 1) {
html += '</p>' isParagraph = false
html += '</p>'
}
} }
} }
} }