vue-stream-markdown 0.7.0-alpha.0 โ†’ 0.7.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +131 -0
  2. package/dist/index.d.ts +1083 -51
  3. package/package.json +9 -8
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # vue-stream-markdown
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![bundle][bundle-src]][bundle-href]
6
+ [![License][license-src]][license-href]
7
+
8
+ A markdown renderer specially optimized for streaming scenarios, inspired by [streamdown](https://streamdown.ai/). Designed to achieve smoother streaming rendering through syntax inference and highly customizable rendering elements.
9
+
10
+ ```sh
11
+ pnpm add vue-stream-markdown
12
+ ```
13
+
14
+ <br>
15
+
16
+ <p align="center">
17
+ <a href="https://docs-vue-stream-markdown.netlify.app/">๐Ÿ“š Documentation</a> |
18
+ <a href="https://play-vue-stream-markdown.netlify.app/">๐Ÿคนโ€โ™‚๏ธ Playground</a>
19
+ </p>
20
+
21
+ <br>
22
+
23
+ <p align='center'>
24
+ <img src='./assets/screenshot.png' alt="screenshot" />
25
+ </p>
26
+
27
+ ## Features
28
+
29
+ - **Streaming-optimized rendering** - Incomplete node completion with loading states for images, tables, and code blocks to prevent visual jitter
30
+ - **Incremental rendering** - Leverages [Shiki](https://shiki.style/)'s `codeToTokens` API for token-level updates, reducing DOM recreation overhead
31
+ - **Progressive Mermaid rendering** - Throttled, streaming-friendly diagram rendering with loading states, supporting both vanilla Mermaid.js and beautiful-mermaid renderers with automatic fallback for unsupported diagram types
32
+ - **Streaming LaTeX rendering** - Progressive math equation rendering with KaTeX support
33
+ - **Interactive controls** - Copy and download buttons for images, tables, and code blocks
34
+ - **Fully customizable** - Replace any AST node or UI component with your own Vue components
35
+ - **Theme-aware scoped styles** - Scoped styles under `.stream-markdown` with semantic `data-stream-markdown` attributes, following [shadcn/ui](https://ui.shadcn.com/) design system
36
+ - **Beautiful built-in typography** - No atomic CSS required (Tailwind/UnoCSS), self-contained styles
37
+ - **Content hardening & security** - Built-in protection against malicious Markdown with URL validation and protocol blocking
38
+ - **SSR support** - Full server-side rendering compatibility with environment detection utilities
39
+
40
+ ## Usage
41
+
42
+ > [!IMPORTANT]
43
+ > ๐Ÿšง **vue-stream-markdown** is currently in active feature development.
44
+ > From version `0.4.0` onwards, you need to manually include `katex.min.css`. If CDN is enabled, it will be automatically loaded.
45
+
46
+ For detailed usage and API documentation, please refer to the [Documentation](https://docs-vue-stream-markdown.netlify.app/).
47
+
48
+ ```vue
49
+ <script setup lang="ts">
50
+ import { ref } from 'vue'
51
+ import { Markdown } from 'vue-stream-markdown'
52
+ // If CDN is enabled, you don't need to manually import katex.min.css
53
+ import 'katex/dist/katex.min.css'
54
+ import 'vue-stream-markdown/index.css'
55
+ // If you don't have shadcn CSS variables globally, import the theme
56
+ import 'vue-stream-markdown/theme.css'
57
+
58
+ const content = ref('# Hello World\n\nThis is a markdown content.')
59
+ </script>
60
+
61
+ <template>
62
+ <Markdown :content="content" />
63
+ </template>
64
+ ```
65
+
66
+ ## Showcase
67
+
68
+ I am grateful to the teams and builders who trust this library in their products:
69
+
70
+ - [AI Elements Vue](https://github.com/vuepont/ai-elements-vue)
71
+ - [ElevenLabs UI Vue](https://elevenlabs-ui-vue.com/)
72
+
73
+ Thank you for your trust and support.
74
+
75
+ ## Credit
76
+
77
+ This project is inspired by [streamdown](https://streamdown.ai/) and even uses some source code from it.
78
+
79
+ This project also uses and benefits from:
80
+
81
+ - [mdast](https://github.com/syntax-tree/mdast) - Markdown Abstract Syntax Tree format
82
+ - [Shiki](https://shiki.style/) - Beautiful syntax highlighting
83
+ - [Mermaid](https://mermaid.js.org/) - Diagramming and charting tool
84
+ - [beautiful-mermaid](https://github.com/notable-next/beautiful-mermaid) - Beautiful Mermaid diagram renderer with Shiki integration
85
+ - [KaTeX](https://katex.org/) - Fast math typesetting library for the web
86
+ - [Remend](https://github.com/vercel/streamdown/tree/main/packages/remend) - This project implements similar functionality inspired by remend for intelligently parsing and completing incomplete Markdown blocks.
87
+
88
+ ### Code Sources
89
+
90
+ - [markstream-vue](https://github.com/Simon-He95/markstream-vue) - The original inspiration for learning AST-based custom markdown rendering, and the source of the animation implementation used in this project
91
+ - [ast-explorer](https://github.com/sxzz/ast-explorer) - Learned AST knowledge from this project, and the playground layout inspiration and AST syntax tree filtering code are derived from it
92
+ - [medium-zoom](https://github.com/francoischalifour/medium-zoom) - Inspired the custom image zoom implementation
93
+ - [markdown-sanitizers](https://github.com/vercel-labs/markdown-sanitizers) - URL validation and security hardening logic in `src/utils/harden.ts` is ported from `rehype-harden`
94
+ - [Dify](https://github.com/langgenius/dify) - LaTeX preprocessing logic in `src/preprocess/vendored/markdown-utils.ts` is ported from Dify
95
+
96
+ ## Acknowledgments
97
+
98
+ I would like to express my sincere gratitude to those who provided guidance and support during the project selection phase and promotion phase of this project. Without their encouragement and support, I would not have been able to complete this work. In particular, the [streamdown](https://streamdown.ai/) community provided excellent code guidance and even helped fix several issues.
99
+
100
+ ## Troubleshooting
101
+
102
+ The playground supports generating shareable links and provides streaming controls (forward/backward navigation) for debugging streaming rendering issues.
103
+
104
+ If you encounter any problems, please:
105
+
106
+ 1. Use the **Generate Share Links** button in the playground to create a shareable link with your current content
107
+ 2. Enable the **AST Result** toggle to view the parsed AST syntax tree
108
+ 3. Copy the markdown content and AST syntax tree at the time of the issue
109
+
110
+ Please provide the shareable link, markdown content, and AST syntax tree when creating an issue. This will help me reproduce and diagnose the problem more effectively.
111
+
112
+ ## Contributors
113
+
114
+ [![Contributors](https://contrib.rocks/image?repo=jinghaihan/vue-stream-markdown)](https://github.com/jinghaihan/vue-stream-markdown/graphs/contributors)
115
+
116
+ ## License
117
+
118
+ [MIT](./LICENSE) License ยฉ [jinghaihan](https://github.com/jinghaihan)
119
+
120
+ <!-- Badges -->
121
+
122
+ [npm-version-src]: https://img.shields.io/npm/v/vue-stream-markdown?style=flat&colorA=080f12&colorB=1fa669
123
+ [npm-version-href]: https://npmjs.com/package/vue-stream-markdown
124
+ [npm-downloads-src]: https://img.shields.io/npm/dm/vue-stream-markdown?style=flat&colorA=080f12&colorB=1fa669
125
+ [npm-downloads-href]: https://npmjs.com/package/vue-stream-markdown
126
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/vue-stream-markdown?style=flat&colorA=080f12&colorB=1fa669&label=minzip
127
+ [bundle-href]: https://bundlephobia.com/result?p=vue-stream-markdown
128
+ [license-src]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat&colorA=080f12&colorB=1fa669
129
+ [license-href]: https://github.com/jinghaihan/vue-stream-markdown/LICENSE
130
+ [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
131
+ [jsdocs-href]: https://www.jsdocs.io/package/vue-stream-markdown