Add image rendering to markdown parser
Support  syntax in comments/descriptions. Images are only rendered for http/https URLs. Style via .md-image (max-width, border, block display) consistent with existing .lt-markdown img rule. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,14 @@ function parseMarkdown(markdown) {
|
||||
html = html.replace(/\*(.+?)\*/g, '<em>$1</em>');
|
||||
html = html.replace(/_(.+?)_/g, '<em>$1</em>');
|
||||
|
||||
// Images  - must come before link handler
|
||||
html = html.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, function(match, alt, url) {
|
||||
if (/^https?:/i.test(url)) {
|
||||
return '<img src="' + url + '" alt="' + alt + '" class="md-image" loading="lazy">';
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
// Links [text](url) - only allow safe protocols
|
||||
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, function(match, text, url) {
|
||||
// Only allow http, https, mailto protocols
|
||||
|
||||
Reference in New Issue
Block a user