filterMarkdown (src/text-transforms.ts)

Patter · libraries/typescript/src/text-transforms.ts · typescript · MIT
voice, Voice / Speech

* Built-in text transforms for cleaning LLM output before TTS synthesis. These functions strip markdown formatting and emoji characters so that TTS engines produce natural-sounding speech rather than reading aloud syntax like "asterisk asterisk bold asterisk asterisk" or Unicode

// Source: https://github.com/PatterAI/Patter | License: MIT | Copyright 2026 Patter Contributors
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Built-in text transforms for cleaning LLM output before TTS synthesis.
 *
 * These functions strip markdown formatting and emoji characters so that TTS
 * engines produce natural-sounding speech rather than reading aloud syntax
 * like "asterisk asterisk bold asterisk asterisk" or Unicode pictographs.
 */

/**
 * Remove markdown formatting from text, preserving the readable content.
 *
 * Handles: headers, bold, italic, code blocks/inline, links, images,
 * strikethrough, list markers, block quotes, horizontal rules, HTML tags.
 */
export function filterMarkdown(text: string): string {
  let result = text;

  // Fenced cod

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

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

Get a free API key