mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
caption element before table is placed as first element of the table (allows markdown tables to have caption)
This commit is contained in:
@@ -125,8 +125,21 @@ export function markdownToHTMLSafe({
|
||||
}
|
||||
|
||||
export function markdownToHtmlNoImages(markdownString: string) {
|
||||
const clean = DOMPurify.sanitize(
|
||||
marked.parse(markdownString, { async: false, pedantic: false, gfm: true })
|
||||
).replaceAll(/>[^<>]*<\/math>/g, "></math>");
|
||||
const parsedHtml = marked.parse(markdownString, {
|
||||
async: false,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
}) as string;
|
||||
|
||||
// Move caption inside table
|
||||
const htmlWithCaptionInTable = parsedHtml.replace(
|
||||
/(<caption[^>]*>[\s\S]*?<\/caption>)\s*(<table[^>]*>)/g,
|
||||
"$2$1"
|
||||
);
|
||||
|
||||
const clean = DOMPurify.sanitize(htmlWithCaptionInTable).replaceAll(
|
||||
/>[^<>]*<\/math>/g,
|
||||
"></math>"
|
||||
);
|
||||
return clean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user