SimpleChatTCRV:Markdown: flexible unwind list

This commit is contained in:
hanishkvc 2025-11-27 12:05:05 +05:30
parent 11eab92d08
commit 82d436b537
2 changed files with 22 additions and 13 deletions

View File

@ -339,3 +339,10 @@ their respective functionalities.
Add support for base64 encoded pdf passing to ai models, when the models and llama engine gain that capability
in turn using openai file - file-data type sub block within content array or so ...
See why the ai streamed response not showing up in TCExternalAi chat session ui, even thou the content is getting
appended to its DivStream. IE why it is hidden.
Markdown if a line which doesnt have any list marker appears at the same offset level as the last list item,
that too after a new line before this ambiguous line, then maybe pop out 1 level wrt the list.

View File

@ -109,15 +109,23 @@ export class MarkDown {
}
}
unwind_list() {
while (true) {
/**
* Unwind till the specified offset level.
* @param {number} unwindTillOffset
*/
unwind_list(unwindTillOffset=-1) {
if (this.in.list.offsets.length == 0) {
return { done: true, remaining: 0 }
}
while (this.in.list.offsets[this.in.list.offsets.length-1] > unwindTillOffset) {
this.in.list.offsets.pop()
let popped = this.in.list.endType.pop()
if (popped == undefined) {
this.html += popped;
if (this.in.list.offsets.length == 0) {
break
}
this.html += popped
}
this.in.list.offsets.length = 0
return { done: true, remaining: this.in.list.offsets.length }
}
/**
@ -154,20 +162,14 @@ export class MarkDown {
this.in.list.endType.push("</ul>\n")
}
} else if (lastOffset > curOffset){
while (this.in.list.offsets[this.in.list.offsets.length-1] > curOffset) {
this.in.list.offsets.pop()
let popped = this.in.list.endType.pop()
this.html += popped;
if (this.in.list.offsets.length == 0) {
break
}
}
this.unwind_list(curOffset)
}
this.html += `<li>${matchList[3]}</li>\n`
return true
} else {
if (this.in.list.offsets.length > 0) {
if (emptyTracker.cur > 0) {
// skip empty line
return true
}
let matchOffset = line.match(/^([ ]*)(.*)$/);