renderMarkdown (components/Markdown.tsx)

memmy-agent · Memory/viewer/src/components/Markdown.tsx · typescript · MIT
ui, tag:embed-classified

Lightweight Markdown renderer for chat bubbles without external deps.

// Source: https://github.com/MemTensor/memmy-agent | License: MIT | Copyright 2026-present MemTensor
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Lightweight Markdown renderer for chat bubbles.
 *
 * Converts a subset of Markdown to HTML without external dependencies.
 * Supports: fenced code blocks, inline code, bold, italic, headers,
 * links, unordered/ordered lists, and line breaks.
 *
 * Security: output is sanitized (no raw HTML passthrough).
 */

import { isSafeLinkTarget } from "../../../core/safety/content";

const ESC: Record<string, string> = {
  "&": "&amp;",
  "<": "&lt;",
  ">": "&gt;",
  '"': "&quot;",
  "'": "&#39;",
};

function esc(s: string): string {
  return s.replace(/[&<>"']/g, (c) => ESC[c] ?? c);
}

export function renderMarkdown(src: st

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key