vue-markdown-viewer
v2.0.1
Published
![npm](https://img.shields.io/npm/v/vue-markdown-viewer) ![npm](https://img.shields.io/npm/dm/vue-markdown-viewer)
Downloads
81
Maintainers
Readme
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 '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>
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 adiv
with this class nameskipHtml
:boolean
, default:false
ignore HTML in markdown completelylinkTarget
:string
target to use on links