ai-markdown

Markdown rendering for AI applications: incremental streaming, LaTeX math, GFM, and CJK typography. Shared engine and core, React and Mantine integrations; Vue

What is ai-markdown?

Markdown rendering for AI applications: incremental streaming, LaTeX math, GFM, and CJK typography. Shared engine and core, React and Mantine integrations; Vue in development.

Overview of ai-markdown

What it is

ai-markdown is a Markdown rendering library for AI applications. It provides incremental streaming, LaTeX math, GFM (GitHub Flavored Markdown), and CJK typography. The library includes a shared engine and core, with React and Mantine integrations; Vue integration is in development. Since version 3.0.0, React and Vue adapters share the public @ai-markdown/core and @ai-markdown/engine packages. The library is designed to handle streaming AI responses where the content changes while the user reads, preserving meaning of intermediate snapshots and managing repeated work efficiently.

Key features

  • GFM: tables, strikethrough, task lists, autolinks (via remark-gfm).
  • LaTeX math: inline $…$ and display $$…$$ via KaTeX, with smart preprocessing for currency $, bracket delimiters (``), pipe escaping, and mhchem commands.
  • Mermaid diagrams: interactive SVG with dark/light themes, source toggle, copy, open-in-new-window (in @ai-markdown/react-mantine).
  • Syntax highlighting: language-labelled tabs, expand/collapse, optional language detection for unlabelled blocks through @ai-markdown/code-language-detector (in @ai-markdown/react-mantine).
  • CJK-friendly: CJK-aware emphasis and strikethrough parsing, source newlines rendered as breaks, plus optional pangu auto-spacing.
  • Streaming-aware: streaming flag propagated via context; custom renderers can show cursors, skip animations, or disable copy buttons during streaming.
  • Streaming cursor: built-in streamingCursor slot renders a “still generating” indicator after the last streamed character.
  • Smooth streaming: reveals bursty token chunks as a steady grapheme-by-grapheme typewriter; three presets (smooth, balanced, responsive) and append frames can use incremental parsing when safety gates permit.
  • Cross-chunk coordination: AIMarkdownDocuments wrapper lets chunked chat messages share a documentId so footnotes, link refs, and image refs resolve across chunks.
  • Block-level memoization: each markdown block is memoized by source identity; unchanged plans reuse React elements during streaming.
  • Emoji shortcodes: :smile: → 😄 via remark-emoji.
  • Extra syntax: ==highlight==, definition lists (PHP Markdown Extra).

Use cases

ai-markdown is intended for AI applications that need to render streaming Markdown with math, GFM, and CJK text. It supports scenarios where an AI response changes while the user reads, such as incremental streaming of chat messages. The library also handles documents with multiple renderers, using AIMarkdownDocuments to share footnote and link/image definitions across logical sections.

Getting started

See the repository README for installation and quick-start commands.

License and pricing

The license is MIT. The project is open source.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/ai-markdownai-markdown.svg)](https://yunodb.com/tools/ai-markdownai-markdown?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/ai-markdownai-markdown?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/ai-markdownai-markdown.svg" alt="Featured on YunoDB" height="20"></a>