Add or improve Markdown parsing and rendering in kheMessage. Use when adding new Markdown syntax support, fixing formatting issues, or enhancing the text editor.
Extend or improve the Markdown parsing and rendering in kheMessage.
The parseMarkdown function in index.html handles Markdown rendering:
function parseMarkdown(element) {
const input = element.textContent
const frag = document.createDocumentFragment()
const matchers = [
{name: 'md-codeblock', re: /```[^\n]*\n[\s\S]*?\n```/y},
{name: 'md-h1', re: /^#[ \t]+[^\n]*$/my},
// ... more matchers
]
// ...
}
Currently supported:
Add a CSS class in the <style> block:
.md-new-syntax {
/* styling */
}
Add a regex matcher to the matchers array:
{name: 'md-new-syntax', re: /pattern/y}
Handle special rendering in the loop if needed