Files
codex-proxy-rs/frontend/src/components/base/BaseMarkdown/markdown.ts
T
ZyyandCodex 4c7e4e08f6 feat: refine admin controls and overload protection
Refine settings navigation, selective pricing sync, model deletion, and admin interactions. Consolidate unreleased migrations and keep Fast policy scoped to groups. Increase confirmed capacity-rejection feedback without changing ordinary failure recovery.

Co-authored-by: Codex <noreply@openai.com>
2026-09-19 06:41:03 +08:00

23 lines
460 B
TypeScript

import DOMPurify from 'dompurify'
import { Marked } from 'marked'
const marked = new Marked({
async: false,
breaks: false,
gfm: true,
})
export function renderMarkdown(source?: string | null) {
const value = source?.trim()
if (!value)
return ''
const html = marked
.parse(value, { async: false })
.replaceAll('<a ', '<a target="_blank" rel="noreferrer" ')
return DOMPurify.sanitize(html, {
ADD_ATTR: ['target', 'rel'],
})
}