cloudacy / vue-markdown-render

A simple markdown parser for Vue using markdown-it.
MIT License
79 stars 10 forks source link

feat: add plugin support #17

Closed AlextheYounga closed 11 months ago

AlextheYounga commented 11 months ago

Description

This change adds the ability to use simple plugins within your vue markdown render component by simply passing plugins as an array of plugin libraries to the vue component props. It works on my machine, but let me know if you have any problems or concerns.

Thanks for building this plugin in the first place!

Example usage:

I wanted to use the MarkdownItAnchor plugin which is why I made this change. Here is how it looks on my project after this change:

<template>
    <main>
        <div id="article-body">
            <vue-markdown :source="markdown" :options="options" :plugins="plugins" />
        </div>
    </main>
</template>

<script setup>
import VueMarkdown from 'vue-markdown-render'
import MarkdownItAnchor from 'markdown-it-anchor';

const options = {
    html: true,
    linkify: true,
}

const plugins = [MarkdownItAnchor]
</script>
p-kuen commented 11 months ago

Can you please open a PR to add your usage example to the README.md? Thanks!