Skip to content

Commit

Permalink
Replace br with br/ for svg
Browse files Browse the repository at this point in the history
  • Loading branch information
philemone committed Jan 23, 2025
1 parent 20eb939 commit c7fbbc6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions designer/client/src/components/graph/EspNode/stickyNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ const escapeHtmlContent = (content: string) =>
const foreignObject = (stickyNote: StickyNote): MarkupNodeJSON => {
try {
const contentWithHtmlTagsSanitized = escapeHtmlContent(stickyNote.content);
const parsed = DOMPurify.sanitize(marked.parse(contentWithHtmlTagsSanitized, { renderer }), { ADD_ATTR: ["target"] });
let parsed = DOMPurify.sanitize(marked.parse(contentWithHtmlTagsSanitized, { renderer }), { ADD_ATTR: ["target"] });
parsed = parsed.replace(/<br\s*\/?>/g, "<br/>"); // SVG does not allow tag without closing and DOMPurify always remove closing tag.
return prepareSvgObject(parsed);
} catch (error) {
console.error("Failed to parse markdown:", error);
return prepareSvgObject("<b>[!] Could not parse markdown content [!]\n</b><br/>" + escapeHtmlContent(stickyNote.content));
console.error("Error: Could not parse markdown:", error);
return prepareSvgObject("<b>[!] Could not parse markdown content [!]\n</b><br></br>" + escapeHtmlContent(stickyNote.content));
}
};

Expand Down

0 comments on commit c7fbbc6

Please sign in to comment.