Skip to content

Introduction โ€‹

Incremark is an incremental Markdown parser designed specifically for AI streaming output scenarios.

Problem Background โ€‹

In AI chat scenarios, AI typically outputs Markdown text in a streaming manner. The traditional approach is:

Receive new chunk โ†’ Concatenate to existing text โ†’ Re-parse complete text โ†’ Re-render

This approach has serious performance issues:

  • Repeated parsing: Already parsed content is parsed repeatedly
  • High CPU overhead: Parsing time grows O(nยฒ) as text increases
  • Page stutters: Poor user experience

Solution โ€‹

Incremark uses an incremental parsing strategy:

Receive new chunk โ†’ Append to buffer โ†’ Detect completed blocks โ†’ Only parse new blocks โ†’ Incremental update

Core Advantages โ€‹

  1. Completed blocks are never re-parsed - Up to 46x faster for long documents
  2. Smart boundary detection - Accurately identify when blocks are complete
  3. Maintain parsing correctness - Handle code blocks, lists and other complex nested structures

Architecture โ€‹

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    @incremark/core                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚   Parser    โ”‚  โ”‚  Detector   โ”‚  โ”‚    Types    โ”‚  โ”‚
โ”‚  โ”‚  Incrementalโ”‚  โ”‚  Boundary   โ”‚  โ”‚   Type Def  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ–ผ               โ–ผ               โ–ผ
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚@incremark/vueโ”‚ โ”‚@incremark/reactโ”‚ โ”‚@incremark/devtoolsโ”‚
   โ”‚  Vue 3      โ”‚ โ”‚  React 18+  โ”‚ โ”‚  Dev Tools   โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Use Cases โ€‹

  • โœ… AI chat applications (ChatGPT, Claude, etc.)
  • โœ… Streaming document generation
  • โœ… Real-time Markdown preview
  • โœ… Low-latency rendering scenarios

Online Demo โ€‹

Try Incremark right now:

  • ๐ŸŽฎ Vue Demo - Vue 3 integration example
  • โš›๏ธ React Demo - React integration example

Next Steps โ€‹

Released under the MIT License.