0.2.10 โ€ข Published 4 years ago

vue-markdown-konishi v0.2.10

Weekly downloads
453
License
MIT
Repository
github
Last release
4 years ago

This fork is intended to work with Webpack 4 and Babel 7, it's open for issues and help is welcome, for now:

Added :

  • markdown-it-container
  • markdown-it-source-map
  • Corrected the source for mardown-it-katex
  • update dependencies to work with Babel V7
  • created a dist folder using Webpack 4 and Babel 7

vue-markdown

npm npm npm

If you want vue-markdown for vue1.X.X, please checkout vue-markdown1.X.X.

A Powerful and Highspeed Markdown Parser for Vue.

Quick start: <vue-markdown>i am a ~~tast~~ **test**.</vue-markdown>

Supported Markdown Syntax:

  • Source map in html (data-source-line="")
  • *SyntaxHighlighter
  • custom container
  • definition list
  • strikethrough
  • GFM task list
  • superscript
  • subscript
  • *katex
  • emoji
  • mark

*SyntaxHighlighter work with Prism recommend

*katex need add katex css.

Example

simple

webpack-simple

Live Demo

Installation

Browser globals

The dist folder contains vue-markdown.js with the component exported in the window.VueMarkdown object.

<body>
  <vue-markdown>i am a ~~tast~~ **test**.</vue-markdown>
</body>
<script src="path/to/vue.js"></script>
<script src="path/to/vue-markdown.js"></script>
<script>
    Vue.use(VueMarkdown);
    var vm = new Vue({
        el: "body"
    });
</script>

NPM

$ npm install --save vue-markdown-konishi

or Yarn

$ yarn add vue-markdown-konishi --save

CommonJS

var VueMarkdown = require('vue-markdown-konishi');

new Vue({
  components: {
    'vue-markdown': VueMarkdown
  }
})

ES6 (Vue-CLI users)

After installing via Yarn or NPM, use the following snippet in the script portion of the Vue component which you wish to render the Markdown.

import VueMarkdown from 'vue-markdown-konishi'

new Vue({
  components: {
    VueMarkdown
  }
})

Slots

<vue-markdown>this is the default slot</vue-markdown>

After setting up the middleware in your vue component above, using the embedded markdown is as easy as writing it between the vue-markdown tags.

VueMarkdown has a default slot which is used to write the markdown source.

TIP: The default slot only renders once at the beginning, and it will overwrite the prop of source!

Props

PropTypeDefaultDescribe
watchesArray["source", "show"]HTML refresh automatically when the prop in this array changed
sourceStringnullthe markdown source code
showBooleantrueenable render to the default slot automatically
htmlBooleantrueenable HTML syntax in source
xhtml-outBooleantrue<br></br> => <br />
breaksBooleantrue\n => <br>
linkifyBooleantrueautoconvert URL-like text to link
emojiBooleantrue:) => ๐Ÿ˜ƒ
sourceMapBooleantrueadd line number in html data attribute
typographerBooleantrueenable some language-neutral replacement and quotes beautification
lang-prefixStringlanguage-CSS language prefix for fenced blocks
quotesStringโ€œโ€โ€˜โ€™use โ€œโ€โ€˜โ€™ for Chinese, โ€žโ€œโ€šโ€˜ for German, ยซยปโ€žโ€œ for Russian
table-classStringtablecustomize html class of the <table>
task-listsBooleantrueenable GFM task list
prerenderFunction (String) Stringnullfilter function before markdown parse
postrenderFunction (String) Stringnullfilter function after markdown parse

Events

NameParamTypeDescribe
renderedoutHtmlStringdispatch when render finish
toc-renderedtocHtmlStringdispatch when TOC render finish, never dispatch if the tocprop is false

Container

Example:

::: danger
*here be dragons*
:::

Will give:

<div class="danger" data-source-line="31">
<p><em>here be dragons</em></p>
</div>

Possible containers:

  • warning
  • info
  • danger
  • success
  • to-left
  • to-right
  • centered
  • justify

Thanks

Contributions

License

Copyright (c) 2016 miaolz123 by MIT