SimpleChatTCRV:MarkDown:Headings, Pre initial cleanup

Remove markdown heading markers

Fix pre equivalent blocks of markdown given that they can have
the block type following ``` marker

Remember to add line break at end of line wrt pre block.
This commit is contained in:
hanishkvc 2025-11-25 20:55:46 +05:30
parent d3f1a398d8
commit c9ddb90aae
1 changed files with 5 additions and 4 deletions

View File

@ -27,18 +27,19 @@ export class MarkDown {
this.in.pre = false
this.html += "</pre>\n"
} else {
this.html += line
this.html += `${line}\n`
}
return
}
if (line.startsWith ("#")) {
let hLevel = lineA[0].length
this.html += `<h${hLevel}>${lineRStripped}</h${hLevel}>\n`
this.html += `<h${hLevel}>${line.slice(hLevel)}</h${hLevel}>\n`
return
}
if (lineA[0] == '```') {
let matchPre = line.match(/^```([a-zA-Z0-9]*)(.*)/);
if ( matchPre != null) {
this.in.pre = true
this.html += "<pre>\n"
this.html += `<pre class="${matchPre[1]}">\n`
return
}
this.html += `<p>${line}</p>`