@stream-markdown/mermaid 0.7.2 → 1.0.0-beta.2

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 (2) hide show
  1. package/README.md +127 -0
  2. package/package.json +16 -3
package/README.md ADDED
@@ -0,0 +1,127 @@
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
+ <p align="center">
11
+ <a href="https://docs-vue-stream-markdown.netlify.app/">Documentation</a> |
12
+ <a href="https://play-vue-stream-markdown.netlify.app/">Playground</a>
13
+ </p>
14
+
15
+ <p align='center'>
16
+ <img src='./assets/screenshot.png' alt="screenshot" />
17
+ </p>
18
+
19
+ ## Features
20
+
21
+ - **Streaming-optimized rendering** - Incomplete node completion with loading states for images, tables, and code blocks to prevent visual jitter
22
+ - **Incremental rendering** - Leverages [Shiki](https://shiki.style/)'s `codeToTokens` API for token-level updates, reducing DOM recreation overhead
23
+ - **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
24
+ - **Streaming LaTeX rendering** - Progressive math equation rendering with KaTeX support
25
+ - **Optional HTML rendering** - Opt in with `@stream-markdown/html` and map safe custom tags to Vue components
26
+ - **Interactive controls** - Copy and download buttons for images, tables, and code blocks
27
+ - **Fully customizable** - Replace any AST node or UI component with your own Vue components
28
+ - **Theme-aware scoped styles** - Scoped styles under `.stream-markdown` with semantic `data-stream-markdown` attributes, following [shadcn/ui](https://ui.shadcn.com/) design system
29
+ - **Beautiful built-in typography** - No atomic CSS required (Tailwind/UnoCSS), self-contained styles
30
+ - **Content hardening & security** - Built-in protection against malicious Markdown with URL validation and protocol blocking
31
+ - **SSR support** - Full server-side rendering compatibility with environment detection utilities
32
+
33
+ ## Usage
34
+
35
+ ```sh
36
+ pnpm add vue-stream-markdown
37
+ ```
38
+
39
+ > [!TIP]
40
+ > The parser layer is also available as standalone packages: `@markmend/core` for streaming-friendly completion, and `@markmend/ast` for MDAST parsing.
41
+
42
+ For detailed usage and API documentation, please refer to the [Documentation](https://docs-vue-stream-markdown.netlify.app/).
43
+
44
+ ```vue
45
+ <script setup lang="ts">
46
+ import { ref } from 'vue'
47
+ import { Markdown } from 'vue-stream-markdown'
48
+ // If CDN is enabled, you don't need to manually import katex.min.css
49
+ import 'katex/dist/katex.min.css'
50
+ import 'vue-stream-markdown/index.css'
51
+ // If you don't have shadcn CSS variables globally, import the theme
52
+ import 'vue-stream-markdown/theme.css'
53
+
54
+ const content = ref('# Hello World\n\nThis is a markdown content.')
55
+ </script>
56
+
57
+ <template>
58
+ <Markdown :content="content" />
59
+ </template>
60
+ ```
61
+
62
+ ## Showcase
63
+
64
+ I am grateful to the teams and builders who trust this library in their products:
65
+
66
+ - [AI Elements Vue](https://github.com/vuepont/ai-elements-vue)
67
+ - [ElevenLabs UI Vue](https://github.com/vuepont/elevenlabs-ui-vue)
68
+
69
+ Thank you for your trust and support.
70
+
71
+ ## Credit
72
+
73
+ This project is inspired by [streamdown](https://streamdown.ai/) and even uses some source code from it.
74
+
75
+ This project also uses and benefits from:
76
+
77
+ - [mdast](https://github.com/syntax-tree/mdast) - Markdown Abstract Syntax Tree format
78
+ - [shiki](https://shiki.style/) - Beautiful syntax highlighting
79
+ - [mermaid](https://mermaid.js.org/) - Diagramming and charting tool
80
+ - [beautiful-mermaid](https://github.com/lukilabs/beautiful-mermaid) - Beautiful Mermaid diagram renderer with Shiki integration
81
+ - [kaTeX](https://katex.org/) - Fast math typesetting library for the web
82
+ - [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.
83
+
84
+ ### Code Sources
85
+
86
+ - [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
87
+ - [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
88
+ - [medium-zoom](https://github.com/francoischalifour/medium-zoom) - Inspired the custom image zoom implementation
89
+ - [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`
90
+ - [dify](https://github.com/langgenius/dify) - LaTeX preprocessing logic in `src/preprocess/vendored/markdown-utils.ts` is ported from Dify
91
+
92
+ ## Acknowledgments
93
+
94
+ 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.
95
+
96
+ ## Troubleshooting
97
+
98
+ The playground supports generating shareable links and provides streaming controls (forward/backward navigation) for debugging streaming rendering issues.
99
+
100
+ If you encounter any problems, please:
101
+
102
+ 1. Use the **Generate Share Links** button in the playground to create a shareable link with your current content
103
+ 2. Enable the **AST Result** toggle to view the parsed AST syntax tree
104
+ 3. Copy the markdown content and AST syntax tree at the time of the issue
105
+
106
+ 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.
107
+
108
+ ## Contributors
109
+
110
+ [![Contributors](https://contrib.rocks/image?repo=jinghaihan/vue-stream-markdown)](https://github.com/jinghaihan/vue-stream-markdown/graphs/contributors)
111
+
112
+ ## License
113
+
114
+ [MIT](./LICENSE) License © [jinghaihan](https://github.com/jinghaihan)
115
+
116
+ <!-- Badges -->
117
+
118
+ [npm-version-src]: https://img.shields.io/npm/v/vue-stream-markdown?style=flat&colorA=080f12&colorB=1fa669
119
+ [npm-version-href]: https://npmjs.com/package/vue-stream-markdown
120
+ [npm-downloads-src]: https://img.shields.io/npm/dm/vue-stream-markdown?style=flat&colorA=080f12&colorB=1fa669
121
+ [npm-downloads-href]: https://npmjs.com/package/vue-stream-markdown
122
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/vue-stream-markdown?style=flat&colorA=080f12&colorB=1fa669&label=minzip
123
+ [bundle-href]: https://bundlephobia.com/result?p=vue-stream-markdown
124
+ [license-src]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat&colorA=080f12&colorB=1fa669
125
+ [license-href]: https://github.com/jinghaihan/vue-stream-markdown/LICENSE
126
+ [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
127
+ [jsdocs-href]: https://www.jsdocs.io/package/vue-stream-markdown
package/package.json CHANGED
@@ -1,10 +1,23 @@
1
1
  {
2
2
  "name": "@stream-markdown/mermaid",
3
3
  "type": "module",
4
- "version": "0.7.2",
4
+ "version": "1.0.0-beta.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
+ "homepage": "https://github.com/jinghaihan/vue-stream-markdown#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/jinghaihan/vue-stream-markdown.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/jinghaihan/vue-stream-markdown/issues"
15
+ },
16
+ "keywords": [
17
+ "stream-markdown",
18
+ "mermaid",
19
+ "beautiful-mermaid"
20
+ ],
8
21
  "exports": {
9
22
  ".": "./dist/index.mjs",
10
23
  "./package.json": "./package.json"
@@ -17,10 +30,10 @@
17
30
  "@antfu/utils": "^9.3.0",
18
31
  "beautiful-mermaid": "^1.1.3",
19
32
  "mermaid": "^11.13.0",
20
- "@stream-markdown/core": "0.7.2"
33
+ "@stream-markdown/core": "1.0.0-beta.2"
21
34
  },
22
35
  "devDependencies": {
23
- "tsdown": "^0.21.10"
36
+ "tsdown": "^0.22.0"
24
37
  },
25
38
  "scripts": {
26
39
  "build": "tsdown"