SimpleChatTCRV:Markdown: Ordered Ya Unordered

Start ordered or unordered list as the case may be and push the
same into endType for matching unwinding.

Ignore empty lines and dont force a list unwind.
This commit is contained in:
hanishkvc 2025-11-26 13:09:43 +05:30
parent 2788752880
commit b4be1cb4b8
1 changed files with 10 additions and 3 deletions

View File

@ -70,8 +70,13 @@ export class MarkDown {
if (lastOffset < curOffset){ if (lastOffset < curOffset){
this.in.list.offsets.push(curOffset) this.in.list.offsets.push(curOffset)
listLvl = this.in.list.offsets.length listLvl = this.in.list.offsets.length
if (matchUnOrdered[2][matchUnOrdered[2].length-1] == '.') {
this.html += "<ol>\n"
this.in.list.endType.push("</ol>\n")
} else {
this.html += "<ul>\n" this.html += "<ul>\n"
this.in.list.endType.push("</ul>\n") this.in.list.endType.push("</ul>\n")
}
} else if (lastOffset > curOffset){ } else if (lastOffset > curOffset){
while (this.in.list.offsets[this.in.list.offsets.length-1] > curOffset) { while (this.in.list.offsets[this.in.list.offsets.length-1] > curOffset) {
this.in.list.offsets.pop() this.in.list.offsets.pop()
@ -192,7 +197,9 @@ export class MarkDown {
if (this.process_list_unordered(line)) { if (this.process_list_unordered(line)) {
return return
} }
if (line.trim().length > 0) {
this.unwind_list() this.unwind_list()
}
this.html += `<p>${line}</p>` this.html += `<p>${line}</p>`
} }