Skip to main content

Module markdown

Module markdown 

Source
Expand description

Markdown sanitizer for platform-specific rendering.

LLM outputs are Markdown. Each chat platform supports a subset of CommonMark. This module converts LLM Markdown into the subset supported by a given platform, stripping or converting unsupported features:

  • Tables → aligned plain text (QQ does not support table syntax)
  • Task lists (- [ ]) → plain unordered lists
  • HTML tags → stripped entirely
  • Images (![]()) → [Image: alt] fallback text
  • Horizontal rules (---) → stripped

Everything else (headings, bold, italic, code, links, lists, blockquotes, strikethrough) is passed through as-is. Parsing uses pulldown-cmark (already in the workspace) for safe event-driven handling, so unsupported syntax inside code blocks is preserved verbatim.

Functions§

prepare_markdown_for_platform
Prepare Markdown for a platform — pass through supported syntax, strip/convert unsupported.