From 226dc793b1bafc35fd7c1340c9ecb6deae5a8935 Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Wed, 26 Nov 2025 14:45:22 +0530 Subject: [PATCH] SimpleChatTCRV:Markdown:Lists - handle split lines to an extent If a split line is found which remains within the constraints of the preceding list item, then dont unwind the list, rather for now add the split line as a new item at the same level. --- tools/server/public_simplechat/typemd.mjs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tools/server/public_simplechat/typemd.mjs b/tools/server/public_simplechat/typemd.mjs index 8a30d90742..48694c6c80 100644 --- a/tools/server/public_simplechat/typemd.mjs +++ b/tools/server/public_simplechat/typemd.mjs @@ -87,9 +87,24 @@ export class MarkDown { } } } - this.html += `
  • ${matchUnOrdered[3]}
  • \n` return true + } else { + if (this.in.list.offsets.length > 0) { + if (line.trim().length == 0) { + return true + } + let matchOffset = line.match(/^([ ]*)(.*)$/); + if (matchOffset == null) { + return false + } + let lastOffset = this.in.list.offsets[this.in.list.offsets.length-1]; + if (matchOffset[1].length < lastOffset) { + return false + } + this.html += `
  • ${matchOffset[2]}
  • \n` + return true + } } return false } @@ -197,9 +212,7 @@ export class MarkDown { if (this.process_list_unordered(line)) { return } - if (line.trim().length > 0) { - this.unwind_list() - } + this.unwind_list() this.html += `

    ${line}

    ` }