### Install TypeScript Types for Markdown-it
Source: https://github.com/cloudacy/vue-markdown-render/blob/master/README.md
This command installs the necessary TypeScript type definitions for the markdown-it library as a development dependency. This is crucial for using markdown-it with TypeScript.
```bash
npm install @types/markdown-it --save-dev
```
--------------------------------
### Configure Markdown-it Options in Vue
Source: https://github.com/cloudacy/vue-markdown-render/blob/master/README.md
This example shows how to pass custom options to the underlying markdown-it instance used by VueMarkdown. Options are passed as a JavaScript object to the 'options' prop.
```vue
```
--------------------------------
### Configuring markdown-it Options for VueMarkdown
Source: https://context7.com/cloudacy/vue-markdown-render/llms.txt
Illustrates how to customize the Markdown rendering behavior by passing configuration options to the 'options' prop of the VueMarkdown component. This example enables HTML rendering, auto-linking URLs, and typographic replacements.
```vue
```
--------------------------------
### Using markdown-it Plugins with VueMarkdown
Source: https://context7.com/cloudacy/vue-markdown-render/llms.txt
Shows how to extend the Markdown rendering capabilities by passing an array of markdown-it plugins to the 'plugins' prop. This example integrates 'markdown-it-anchor' for anchor links and 'markdown-it-toc-done-right' for table of contents generation.
```vue
```
--------------------------------
### Integrate Markdown-it Plugins in Vue
Source: https://github.com/cloudacy/vue-markdown-render/blob/master/README.md
This snippet illustrates how to enable markdown-it plugins within the VueMarkdown component. Plugins are provided as an array to the 'plugins' prop. This example uses MarkdownItAnchor.
```vue
```
--------------------------------
### Basic VueMarkdown Component Usage
Source: https://context7.com/cloudacy/vue-markdown-render/llms.txt
Demonstrates the fundamental usage of the VueMarkdown component to render a Markdown string. It shows how to import the component and pass a Markdown string to the 'source' prop. The component reactively updates when the source changes.
```vue
```
--------------------------------
### Reactive Markdown Rendering with VueMarkdown
Source: https://context7.com/cloudacy/vue-markdown-render/llms.txt
Demonstrates the reactive nature of the VueMarkdown component. Changes to the 'source' prop, driven by user input or other reactive data like a counter, automatically update the rendered HTML. This enables features like live previews.
```vue
```
--------------------------------
### Test VueMarkdown Component Rendering with Vue Test Utils
Source: https://context7.com/cloudacy/vue-markdown-render/llms.txt
Tests the VueMarkdown component to ensure it correctly renders Markdown content into HTML. It mounts the component with a source prop containing Markdown and asserts that the expected HTML tags are present in the output. It also tests the behavior when the 'html' option is disabled, ensuring tags are escaped.
```typescript
import { describe, it, expect } from 'vitest'
import { shallowMount } from '@vue/test-utils'
import VueMarkdown from 'vue-markdown-render'
describe('VueMarkdown', () => {
it('renders markdown as HTML', () => {
const source = '# Heading\n\n**Bold text** and *italic*'
const wrapper = shallowMount(VueMarkdown, {
props: {
source,
options: { html: true }
}
})
expect(wrapper.html()).toContain('
Heading
')
expect(wrapper.html()).toContain('Bold text')
expect(wrapper.html()).toContain('italic')
})
it('escapes HTML when html option is false', () => {
const wrapper = shallowMount(VueMarkdown, {
props: {
source: '',
options: { html: false }
}
})
// HTML tags should be escaped, not rendered
expect(wrapper.html()).toContain('<script>')
expect(wrapper.html()).not.toContain('
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.