vue-markdown-viewer
vue-markdown-viewer
Vue component to render markdown with remark.
Install
$ npm install vue-markdown-viewer
Use
<script lang="ts" setup>
import { ref } from 'vue'
import { VueMarkdownRender } from 'core'
const md = ref('## hi')
</script>
<template>
<VueMarkdownRender>{{ md }}</VueMarkdownRender>
</template>
Use a plugin to support gfm:
<script lang="ts" setup>
import { ref } from 'vue'
import { VueMarkdownRender } from 'core'
import remarkGfm from 'remark-gfm'
const md = ref('## hi')
</script>
<template>
<VueMarkdownRender :remark-plugins="[remarkGfm]">
{{ md }}
</VueMarkdownRender>
</template>
Use a plugin to support syntax highlight:
<script lang="ts" setup>
import { ref } from 'vue'
import { VueMarkdownRender } from 'core'
import rehypeHighlight from 'rehype-highlight'
const md = ref(`
## Highlight
```js
console.log("hi")
```
`)
</script>
<template>
<VueMarkdownRender :rehype-plugins="[rehypeHighlight]">
{{ md }}
</VueMarkdownRender>
</template>
Options
content:string
markdown stringcomponents:Record<string, Component>
object mapping tag names to Vue componentsremarkRehypeOptions:Record<string, any>
Options of remark-rehyperemarkPlugins:Array
list of remark plugins to userehypePlugins:Array
list of rehype plugins to useclassName:string
wrap the markdown in adivwith this class nameskipHtml:boolean, default:false
ignore HTML in markdown completelylinkTarget:string
target to use on links
Related
Related Packages
remark-generic-extensions
!Extension\[Content\]\(Argument\)\{Properties\} -> :tada: — commonmark generic d...
8,508
25
Version History
| Version | Released | License |
|---|---|---|
| 2.0.2 | MIT | |
| 2.0.1 | MIT | |
| 2.0.0 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT |