Projects
View on GitHub
kingshuaishuai/incremark
About
传统 Markdown 解析器每次收到新内容都会重新解析整个文档,导致 O(n²) 的复杂度。Incremark 的增量解析实现了 O(n) —— 文档越大,优势越明显:
Other ProjectsMeasured star growth
- in 24h
- 0
- in 7 days
- -1
- in 15 days
- -1
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.en.md
OriginalIncremark
Incremental Markdown parser designed for AI streaming output.
🇨🇳 中文 | 🇺🇸 English
📖 Documentation | 🎮 Vue Demo | ⚛️ React Demo
Why Incremark?
Traditional Markdown parsers re-parse the entire document on every new chunk, leading to O(n²) complexity. Incremark's incremental parsing achieves O(n) — the larger the document, the more pronounced the advantage:
| File | Lines | Incremark | Streamdown | markstream | ant-design-x |
|---|---|---|---|---|---|
| concepts.md | 91 | 12.0 ms | 50.5 ms (4.2x) | 381.9 ms (31.9x) | 53.6 ms (4.5x) |
| comparison.md | 109 | 20.5 ms | 74.0 ms (3.6x) | 552.2 ms (26.9x) | 85.2 ms (4.1x) |
| complex-html.md | 147 | 9.0 ms | 58.8 ms (6.6x) | 279.3 ms (31.1x) | 57.2 ms (6.4x) |
| OPTIMIZATION_SUMMARY.md | 391 | 19.1 ms | 208.4 ms (10.9x) | 980.6 ms (51.3x) | 217.8 ms (11.4x) |
| test-md-01.md | 916 | 87.7 ms | 1441.1 ms (16.4x) | 5754.7 ms (65.6x) | 1656.9 ms (18.9x) |
| Total (38 files) | 6484 | 519.4 ms | 3190.3 ms (6.1x) | 14683.9 ms (28.3x) | 3728.6 ms (7.2x) |
📊 Benchmark: 38 real Markdown files, 128.55 KB total. View full results →
Packages
| Package | Description | Version |
|---|---|---|
| @incremark/core | Core parser | |
| @incremark/vue | Vue 3 integration | |
| @incremark/react | React integration | |
| @incremark/devtools | Developer tools |
Quick Start
Vue
pnpm add @incremark/vue @incremark/theme
<script setup>
import { ref } from 'vue'
import { IncremarkContent } from '@incremark/vue'
import '@incremark/theme/styles.css'
const content = ref('')
const isFinished = ref(false)
async function handleAIStream(stream) {
for await (const chunk of stream) {
content.value += chunk
}
isFinished.value = true
}
</script>
<template>
<IncremarkContent :content="content" :is-finished="isFinished" />
</template>
React
pnpm add @incremark/react @incremark/theme
import { useState } from 'react'
import { IncremarkContent } from '@incremark/react'
import '@incremark/theme/styles.css'
function App() {
const [content, setContent] = useState('')
const [isFinished, setIsFinished] = useState(false)
async function handleAIStream(stream: ReadableStream) {
const reader = stream.getReader()
while (true) {
const { done, value } = await reader.read()
if (done) break
setContent(prev => prev + new TextDecoder().decode(value))
}
setIsFinished(true)
}
return <IncremarkContent content={content} isFinished={isFinished} />
}
Features
- ⚡ Incremental Parsing - Only parse new content
- 🔄 Streaming Friendly - Supports char-by-char/line-by-line input
- 🎯 Boundary Detection - Smart block boundary recognition
- 🔌 Framework Agnostic - Core library works independently
- 📊 DevTools - Built-in developer tools
- 🎨 Customizable - Support for custom render components
- 📐 Extension Support - GFM, Math formulas, Mermaid, etc.
Development
# Install dependencies
pnpm install
# Start development
pnpm dev
# Run Vue example
pnpm example:vue
# Run React example
pnpm example:react
# Start documentation
pnpm docs
# Run tests
pnpm test
# Build
pnpm build
Roadmap
- 🔧 DevTools Svelte Rewrite
- 🎨 Theme Package Separation
- 🟠 Svelte / ⚡ Solid Support
- 💭 AI Scenarios (thinking block, tool call, citations)
Documentation
Full documentation available at: https://www.incremark.com/
Live Demos
- 🎮 Vue Demo - Vue 3 integration example
- ⚛️ React Demo - React integration example
License
MIT
Explore related projects
Loading…