diff --git a/tools/server/public_simplechat/docs/changelog.md b/tools/server/public_simplechat/docs/changelog.md index 9d642de0a1..98010de0d9 100644 --- a/tools/server/public_simplechat/docs/changelog.md +++ b/tools/server/public_simplechat/docs/changelog.md @@ -303,6 +303,7 @@ Chat Session specific settings * A simple minded basic Markdown to Html logic with support for below to some extent * headings, horiz line, * lists (ordered, unordered, intermixed at diff leves) + accomodate lines without list markers inbetween list items to some extent, hopefully in a sane way. * tables, fenced code blocks, blockquotes * Rename fetch_web_url_raw to fetch_url_raw, avoids confusion and matchs semantic of access to local and web. @@ -342,7 +343,3 @@ 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. - diff --git a/tools/server/public_simplechat/typemd.mjs b/tools/server/public_simplechat/typemd.mjs index da42938063..5243167fc6 100644 --- a/tools/server/public_simplechat/typemd.mjs +++ b/tools/server/public_simplechat/typemd.mjs @@ -130,14 +130,24 @@ export class MarkDown { /** * Process list one line at a time. - * * Account for ordered lists as well as unordered lists, including intermixing of the lists. - * at different list hierarchy levels. - * * Allow a list item line to be split into multiple lines provided the split lines retain - * the same or more line offset compared to the starting line of the item to which they belong. - * * if there is a empty line in between, then the new line will be treated as a new item. - * * allows for empty lines inbetween items. - * * currently there is no limit on the number of empty lines. - * but may bring in a limit later. + * + * Account for ordered lists as well as unordered lists, including intermixing of the lists. + * * inturn at different list hierarchy levels. + * + * Allow a list item line to be split into multiple lines provided the split lines retain + * the same or more line offset compared to the starting line of the item to which they belong. + * * these following split lines wont have the list marker in front of them. + * + * Allows for empty lines inbetween items (ie lines with list marker) + * * currently there is no limit on the number of empty lines, but may bring in a limit later. + * + * If empty line between a list item and new line with some content, but without a list marker + * * if content offset less than last list item, then unwind the lists before such a line. + * * if content offset larger than last list item, then line will be added as new list item + * at the same level as the last list item. + * * if content offset same as last list item, then unwind list by one level and insert line + * as a new list item at this new unwound level. + * * @param {string} line */ process_list(line) { @@ -168,6 +178,7 @@ export class MarkDown { return true } else { if (this.in.list.offsets.length > 0) { + if (emptyTracker.cur > 0) { // skip empty line return true @@ -180,8 +191,24 @@ export class MarkDown { if (matchOffset[1].length < lastOffset) { return false } - this.extend_else_appendnew(matchOffset[2], "\n", '