diff --git a/bun.lockb b/bun.lockb index 5c6b35a..8f677ae 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 9338826..36d25e3 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "cassandra-driver": "^4.7.2", "express": "^4.21.2", "lucide-svelte": "^0.474.0", + "markdown-it-highlightjs": "^4.2.0", "mode-watcher": "^0.5.1", "socket.io": "^4.8.1", "socket.io-client": "^4.8.1", diff --git a/src/app.css b/src/app.css index 8950353..e496cfd 100644 --- a/src/app.css +++ b/src/app.css @@ -1,3 +1,5 @@ +@import '../node_modules/highlight.js/styles/github-dark.min.css'; + @tailwind base; @tailwind components; @tailwind utilities; diff --git a/src/lib/components/message.svelte b/src/lib/components/message.svelte index 9804cc2..cc570ac 100644 --- a/src/lib/components/message.svelte +++ b/src/lib/components/message.svelte @@ -14,7 +14,7 @@

{user}

- {@html renderMarkdown(escapeHTML(message))} + {@html renderMarkdown(message)}
diff --git a/src/lib/functions/renderMarkdown.ts b/src/lib/functions/renderMarkdown.ts index fec455d..98c0b50 100644 --- a/src/lib/functions/renderMarkdown.ts +++ b/src/lib/functions/renderMarkdown.ts @@ -1,4 +1,5 @@ import markdownit from 'markdown-it'; +import highlightjs from 'markdown-it-highlightjs'; export default function renderMarkdown(input: string): string { const md = markdownit({ @@ -6,7 +7,10 @@ export default function renderMarkdown(input: string): string { linkify: true, typographer: true, breaks: true, - }).disable(['image', 'table']); + }); + + md.disable(['image', 'table']); + md.use(highlightjs); return md.render(input); } diff --git a/tailwind.config.ts b/tailwind.config.ts index 7cfa67e..f2ec7f9 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -53,11 +53,24 @@ const config: Config = { borderRadius: { lg: 'var(--radius)', md: 'calc(var(--radius) - 2px)', + 'background-color': '#22272E', sm: 'calc(var(--radius) - 4px)', }, fontFamily: { sans: [...fontFamily.sans], }, + typography: () => ({ + DEFAULT: { + css: { + pre: { + 'background-color': '#22272E', + code: { + 'background-color': '#22272E', + }, + }, + }, + }, + }), }, }, plugins: [typography],