Vue component to render markdown with remark.
$ npm install vue-markdown-viewer
<script lang="ts" setup>
import { ref } from 'vue'
import { VueMarkdownRender } from 'vue-markdown-viewer'
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 'vue-markdown-viewer'
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 'vue-markdown-viewer'
import rehypeHighlight from 'rehype-highlight'
const md = ref(`
## Highlight
```js
console.log("hi")
```
`)
</script>
<template>
<VueMarkdownRender :rehype-plugins="[rehypeHighlight]">
{{ md }}
</VueMarkdownRender>
</template>
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 adiv
with this class nameskipHtml
:boolean
, default:false
ignore HTML in markdown completelylinkTarget
:string
target to use on links