Skip to content

Commit 5c42fde

Browse files
committed
fix#24 reduce bundle size & light model support
1 parent 40d493a commit 5c42fde

17 files changed

+3307
-25
lines changed

README.md

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ npm install markdown-it-vue
2121
- GFM style
2222
- emoji
2323
- [mermaid charts](http://knsv.github.io/mermaid/)
24-
- [Echarts](http://echarts.baidu.com)
24+
- [Echarts](http://echarts.baidu.com) **simple only**
2525
- Flowcharts.js
2626
- Subscript/Superscript
2727
- [AsciiMath](http://asciimath.org/)
@@ -40,7 +40,6 @@ npm install markdown-it-vue
4040
- markdown-it-mark
4141
- markdown-it-katex
4242
- markdown-it-task-lists
43-
- markdown-it-icons
4443
- markdown-it-highlight
4544
- markdown-it-latex
4645
- markdown-it-container
@@ -50,6 +49,9 @@ npm install markdown-it-vue
5049

5150
internal plugin list:
5251

52+
- markdown-it-font-awsome
53+
- markdown-it-link-attributes
54+
- markdown-it-highlight
5355
- markdown-it-plugin-echarts
5456
- markdown-it-plugin-mermaid
5557
- markdown-it-plugin-flowchart
@@ -113,6 +115,67 @@ it can add your plugin to markdown-it-vue by the `use` method.
113115
this.$refs.myMarkdownItVue.use(MyMarkdownItPlugin)
114116
```
115117

118+
## support hilight lang
119+
120+
PR for you lang wich you want.
121+
122+
- html
123+
- json
124+
- css
125+
- shell
126+
- bash
127+
- C
128+
- Java
129+
- Python
130+
- C++
131+
- C#
132+
- PHP
133+
- SQL
134+
- R
135+
- Swift
136+
- Go
137+
- MATLAB
138+
- Ruby
139+
- Perl
140+
- Objective-C
141+
- Rust
142+
- Dart
143+
- Delphi
144+
- D
145+
- Kotlin
146+
- Scala
147+
- SAS
148+
- Lisp
149+
- Lua
150+
- Ada
151+
- Fortran
152+
- PowerShell
153+
- VBScript
154+
- VBscript-html
155+
- Groovy
156+
- Julia
157+
- Julia-repl
158+
- LabVIEW
159+
- Haskell
160+
- ActionScript
161+
- Scheme
162+
- TypeScript
163+
- F#
164+
- Prolog
165+
- Erlang
166+
167+
## about echarts
168+
169+
use echarts.simple to reduce the bundle size.
170+
171+
## markdown-it-vue-light
172+
173+
markdown-it-vue-light remove the mermaid chart to reduce the bundle size.
174+
175+
https://github.com/ravenq/markdown-it-vue/issues/24
176+
177+
for a small bundle size, it better to import the markdown-it-vue-light.
178+
116179
## Usage
117180

118181
```vue
@@ -138,6 +201,31 @@ export default {
138201
</script>
139202
```
140203

204+
the light model.
205+
206+
```vue
207+
<template>
208+
<div>
209+
<markdown-it-vue-light class="md-body" :content="content" />
210+
</div>
211+
</template>
212+
213+
<script>
214+
import MarkdownItVueLight from 'markdown-it-vue/dist/markdown-it-vue-light.umd.min.js'
215+
import 'markdown-it-vue/dist/markdown-it-vue-light.css'
216+
export default {
217+
components: {
218+
MarkdownItVueLight
219+
},
220+
data() {
221+
return {
222+
content: '# your markdown content'
223+
}
224+
}
225+
}
226+
</script>
227+
```
228+
141229
## ScreenShot
142230

143231
![markdown-it-vue](https://github.com/ravenq/markdown-it-vue/blob/master/doc/markdown-it-vue.png?raw=true)

README_CN.md

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ npm install markdown-it-vue
5454

5555
内置插件:
5656

57+
* markdown-it-font-awsome
58+
* markdown-it-link-attributes
59+
* markdown-it-highlight
5760
* markdown-it-plugin-echarts
5861
* markdown-it-plugin-mermaid
5962
* markdown-it-plugin-flowchart
@@ -111,14 +114,77 @@ options: {
111114

112115
个插件详细说明见个插件官方文档。
113116

114-
## More plugins
117+
## 自定义插件
115118

116119
it can add your plugin to markdown-it-vue by the `use` method.
117120

118121
```js
119122
this.$refs.myMarkdownItVue.use(MyMarkdownItPlugin)
120123
```
121124

125+
## 支持高亮的语言
126+
127+
语言高亮使用 hilight.js 打包过大,因此只引用了常用的语言。
128+
129+
如果这里没有你需要的语言,欢迎提 PR。
130+
131+
- html
132+
- json
133+
- css
134+
- shell
135+
- bash
136+
- C
137+
- Java
138+
- Python
139+
- C++
140+
- C#
141+
- PHP
142+
- SQL
143+
- R
144+
- Swift
145+
- Go
146+
- MATLAB
147+
- Ruby
148+
- Perl
149+
- Objective-C
150+
- Rust
151+
- Dart
152+
- Delphi
153+
- D
154+
- Kotlin
155+
- Scala
156+
- SAS
157+
- Lisp
158+
- Lua
159+
- Ada
160+
- Fortran
161+
- PowerShell
162+
- VBScript
163+
- VBscript-html
164+
- Groovy
165+
- Julia
166+
- Julia-repl
167+
- LabVIEW
168+
- Haskell
169+
- ActionScript
170+
- Scheme
171+
- TypeScript
172+
- F#
173+
- Prolog
174+
- Erlang
175+
176+
## 关于 echarts
177+
178+
为了减少包的大小,只引用 echarts.simple。
179+
180+
## 精简版 markdown-it-vue-light
181+
182+
https://github.com/ravenq/markdown-it-vue/issues/24
183+
184+
为了进一步缩小打包的大小,移除了 mermaid chart。这包直接引用了整个 lodash, 他本身也很大。
185+
186+
如果平时用不到的话,就用精简版吧。
187+
122188
## 使用示例
123189

124190
```vue
@@ -144,6 +210,31 @@ export default {
144210
</script>
145211
```
146212

213+
使用精简版
214+
215+
```vue
216+
<template>
217+
<div>
218+
<markdown-it-vue-light class="md-body" :content="content" />
219+
</div>
220+
</template>
221+
222+
<script>
223+
import MarkdownItVueLight from 'markdown-it-vue/dist/markdown-it-vue-light.umd.min.js'
224+
import 'markdown-it-vue/dist/markdown-it-vue-light.css'
225+
export default {
226+
components: {
227+
MarkdownItVueLight
228+
},
229+
data() {
230+
return {
231+
content: '# your markdown content'
232+
}
233+
}
234+
}
235+
</script>
236+
```
237+
147238
## 示例截图
148239

149240
![markdown-it-vue](https://github.com/ravenq/markdown-it-vue/blob/master/doc/markdown-it-vue.png?raw=true)

example/components/example.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,34 @@ The width and height is the size for chart container.
150150
151151
## code
152152
153+
### c
154+
\`\`\`c
155+
#include <stdio.h>
156+
int main(int argc char* argv[]) {
157+
printf("Hello, World!");
158+
return 0;
159+
}
160+
\`\`\`
161+
162+
### json
163+
164+
\`\`\`json
165+
{
166+
"name": "markdown-it-vue"
167+
}
168+
\`\`\`
169+
170+
### javascript
171+
\`\`\`json
172+
import MarkdownItVue from 'markdown-it-vue'
173+
export default {
174+
components: {
175+
MarkdownItVue
176+
}
177+
}
178+
\`\`\`
179+
180+
### bash
153181
\`\`\`bash
154182
npm install markdown-it-vue
155183
\`\`\`
@@ -187,4 +215,4 @@ para(path2, right)->op2->e
187215
st@>op1({"stroke":"Red"})@>cond({"stroke":"Red","stroke-width":6,"arrow-end":"classic-wide-long"})@>c2({"stroke":"Red"})@>op2({"stroke":"Red"})@>e({"stroke":"Red"})
188216
\`\`\`
189217
190-
`;
218+
`

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "markdown-it-vue",
3-
"version": "1.0.11",
3+
"version": "1.1.0",
44
"private": false,
55
"description": "The vue lib for markdown-it",
66
"author": {
@@ -21,25 +21,25 @@
2121
],
2222
"scripts": {
2323
"dev": "vue-cli-service serve ./example/main.js",
24-
"build": "npm run build:lib && npm run build:example",
24+
"build": "npm run build:lib && npm run build:light && npm run build:example",
2525
"lint": "vue-cli-service lint",
2626
"build:example": "node --max_old_space_size=8192 node_modules/@vue/cli-service/bin/vue-cli-service.js build --dest example/dist ./example/main.js",
27-
"build:lib": "node --max_old_space_size=8192 node_modules/@vue/cli-service/bin/vue-cli-service.js build --target lib ./src/index.js"
27+
"build:lib": "node --max_old_space_size=8192 node_modules/@vue/cli-service/bin/vue-cli-service.js build --target lib ./src/index.js",
28+
"build:light": "node --max_old_space_size=8192 node_modules/@vue/cli-service/bin/vue-cli-service.js build --target lib --name markdown-it-vue-light ./src/index-light.js"
2829
},
2930
"main": "dist/markdown-it-vue.umd.min.js",
3031
"dependencies": {
3132
"echarts": "^4.5.0",
3233
"flowchart.js": "^1.13.0",
3334
"github-markdown-css": "^3.0.1",
34-
"highlight.js": "^9.16.2",
35+
"highlight.js": "^10.0.3",
3536
"markdown-it": "^10.0.0",
3637
"markdown-it-abbr": "^1.0.4",
3738
"markdown-it-container": "^2.0.0",
3839
"markdown-it-deflist": "^2.0.3",
3940
"markdown-it-emoji": "^1.4.0",
4041
"markdown-it-footnote": "^3.0.1",
4142
"markdown-it-github-toc": "^3.2.4",
42-
"markdown-it-icons": "^0.4.1",
4343
"markdown-it-ins": "^3.0.0",
4444
"markdown-it-katex": "^2.0.3",
4545
"markdown-it-latex": "^0.2.0",
@@ -60,6 +60,7 @@
6060
"eslint": "^6.7.2",
6161
"eslint-plugin-vue": "^5.0.0",
6262
"vue-cli-plugin-component-lib": "^0.1.6",
63+
"vue-cli-plugin-webpack-bundle-analyzer": "^2.0.0",
6364
"vue-template-compiler": "^2.5.21"
6465
},
6566
"eslintConfig": {

src/index-light.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import MarkdownItVueLight from './markdown-it-vue-light'
2+
3+
const install = function (Vue) {
4+
Vue.component(MarkdownItVueLight.name, MarkdownItVueLight)
5+
}
6+
7+
/* istanbul ignore if */
8+
if (typeof window !== 'undefined' && window.Vue) {
9+
install(window.Vue)
10+
}
11+
12+
MarkdownItVueLight.install = install
13+
export default MarkdownItVueLight

src/markdown-it-font-awsome/font-awsome/css/font-awesome.min.css

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)