import DOMPurify from 'dompurify' import { highlightCode } from '../utils/latex' import type { Question } from '../types' interface Props { q: Question } export default function QuestionMedia({ q }: Props) { return ( <> {q.image && (
{q.image.alt {q.image.caption && (
{q.image.caption}
)}
)} {q.audio && (
)} {q.code && ( // highlightCode runs escapeHtml on the source first — output is safe
      )}
      {q.table && (
        {q.table.headers.map((h, i) => )}
            {q.table.rows.map((row, i) => (
              {row.map((cell, j) => )}
            ))}
          
{h}
{cell}
)} {q.svg && ( // SVG is user-provided — sanitize with DOMPurify before rendering
)} ) }