Allow removing images and wrap tables with scroll container

This commit is contained in:
thiloho
2025-01-11 20:59:36 +01:00
parent d570fb6906
commit 24d81a8e4d
8 changed files with 75 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import { Marked } from "marked";
import type { Renderer, Token } from "marked";
import { Marked, Renderer } from "marked";
import type { Token } from "marked";
import { markedHighlight } from "marked-highlight";
import hljs from "highlight.js";
import DOMPurify from "isomorphic-dompurify";
@@ -40,6 +40,7 @@ const slugify = (string: string) => {
const createMarkdownParser = (showToc = true) => {
const marked = new Marked();
const renderer = new Renderer();
marked.use({
async: false,
@@ -58,6 +59,14 @@ const createMarkdownParser = (showToc = true) => {
})
);
marked.use({
renderer: {
table(...args) {
return `<div class="scroll-container">${renderer.table.apply(this, args)}</div>`;
}
}
});
const gfmHeadingId = ({ prefix = "", showToc = true } = {}) => {
const headings: { text: string; level: number; id: string }[] = [];
const sectionStack: { level: number; id: string }[] = [];