SimpleChatTCRV:Markdown: Allow fixed spaces b4 fenced pre marker

This commit is contained in:
hanishkvc 2025-11-25 23:43:21 +05:30
parent 95c8cd6eba
commit 03220d4a2b
2 changed files with 7 additions and 1 deletions

View File

@ -299,6 +299,7 @@ Chat Session specific settings
* More flexibility to user wrt ExternalAi tool call ie ai calling ai
* the user can change the default behaviour of tools being disabled and sliding window of 1
* program restart will reset these back to the default
* A simple minded basic Markdown to Html logic
## ToDo

View File

@ -43,6 +43,8 @@ export class MarkDown {
}
return
}
// 3 or more of --- or ___ or *** followed by space
// some online notes seemed to indicate spaces at end, so accepting same
if (line.match(/^[-]{3,}|[*]{3,}|[_]{3,}\s*$/) != null) {
this.unwind_list()
this.html += "<hr>\n"
@ -54,13 +56,16 @@ export class MarkDown {
this.html += `<h${hLevel}>${line.slice(hLevel)}</h${hLevel}>\n`
return
}
let matchPreFenced = line.match(/^(```|~~~)([a-zA-Z0-9]*)(.*)/);
// same number of space followed by ``` or ~~~
// some samples with spaces at beginning seen, so accepting spaces at begin
let matchPreFenced = line.match(/^(\s*```|\s*~~~)([a-zA-Z0-9]*)(.*)/);
if ( matchPreFenced != null) {
this.unwind_list()
this.in.preFenced = matchPreFenced[1]
this.html += `<pre class="${matchPreFenced[2]}">\n`
return
}
// spaces followed by - or + or * followed by a space and actual list item
let matchUnOrdered = line.match(/^([ ]*)[-+*][ ](.*)$/);
if ( matchUnOrdered != null) {
let sList = 'none'