no message
Former-commit-id: 0a96bb54e9270e451e59b72e00e35053a7c0e152 Former-commit-id: c250ba90da6546626b9831847630aae786c88344 Former-commit-id: c1182b1bdc6ea9b3934275286a93e2760a643bfe
This commit is contained in:
40
src/pages/demo/plugins/marked/demo.vue
Normal file
40
src/pages/demo/plugins/marked/demo.vue
Normal file
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<Container type="ghost">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="12">
|
||||
<el-card>
|
||||
<p slot="title">markdown 源码</p>
|
||||
<pre>{{mdSource}}</pre>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-card>
|
||||
<p slot="title">markdown 解析结果</p>
|
||||
<div class="markdown-body" v-html="markedHTML"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import marked from 'marked'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
mdSource: '',
|
||||
markedHTML: ''
|
||||
}
|
||||
},
|
||||
async mounted () {
|
||||
this.mdSource = await this.getReadme(this.url)
|
||||
this.markedHTML = marked(this.mdSource)
|
||||
},
|
||||
methods: {
|
||||
async getReadme () {
|
||||
const { data } = await this.$axios.get('/static/markdownFiles/demo/baseMarkdowmFile.md')
|
||||
return data
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
45
src/pages/demo/plugins/marked/demoHighlight.vue
Normal file
45
src/pages/demo/plugins/marked/demoHighlight.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<Container type="ghost">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="12">
|
||||
<el-card>
|
||||
<p slot="title">markdown 源码</p>
|
||||
<pre>{{mdSource}}</pre>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-card>
|
||||
<p slot="title">markdown 解析结果 代码高亮显示</p>
|
||||
<div class="markdown-body" v-html="markedHTML"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import marked from 'marked'
|
||||
import highlight from 'highlight.js'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
mdSource: '',
|
||||
markedHTML: ''
|
||||
}
|
||||
},
|
||||
async mounted () {
|
||||
this.mdSource = await this.getReadme(this.url)
|
||||
this.markedHTML = marked(this.mdSource, {
|
||||
highlight: (code) => {
|
||||
return highlight.highlightAuto(code).value
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
async getReadme () {
|
||||
const { data } = await this.$axios.get('/static/markdownFiles/demo/baseMarkdowmFile.md')
|
||||
return data
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
7
src/pages/demo/plugins/marked/readme.vue
Normal file
7
src/pages/demo/plugins/marked/readme.vue
Normal file
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<Container>
|
||||
<p slot="title">README.md</p>
|
||||
<p slot="more"><GithubLink url="https://github.com/chjj/marked"></GithubLink></p>
|
||||
<Markdown url="https://raw.githubusercontent.com/chjj/marked/master/README.md"></Markdown>
|
||||
</Container>
|
||||
</template>
|
||||
Reference in New Issue
Block a user