style: modified returned markdown to be more user-friendly.
This commit is contained in:
parent
579045d933
commit
c9676e17a7
|
|
@ -9,7 +9,7 @@ const props = defineProps<{
|
|||
|
||||
// Initialize Markdown parser
|
||||
const md = new MarkdownIt({
|
||||
breaks: true, // Support line breaks
|
||||
breaks: false, // Support line breaks
|
||||
linkify: true, // Make URLs clickable
|
||||
html: false // Prevent raw HTML injection
|
||||
})
|
||||
|
|
@ -17,7 +17,11 @@ const md = new MarkdownIt({
|
|||
// Removes all the h1,h2,h3 to make the Md more user friendly
|
||||
const cleanMarkdown = (markdown: string): string => {
|
||||
if (!markdown) return ''
|
||||
return markdown.replace(/^#{1,3}\s(.*)$/gm, '#### $1')
|
||||
return markdown
|
||||
.replace(/\r\n/g, '\n') // normalize Windows line endings
|
||||
.replace(/([.!?])(\s+)(?=[A-Z])/g, '$1\n') // insert line break after sentence-ending punctuation
|
||||
.replace(/\n{3,}/g, '\n\n') // squash triple+ line breaks
|
||||
.replace(/^#{1,3}\s(.*)$/gm, '#### $1') // downgrade headings
|
||||
}
|
||||
|
||||
// Compute parsed content
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user