medfreeman / remark-vue

Compile Markdown to Vue with remark
MIT License
15 stars 1 forks source link
compile html markdown remark stringify vuejs2

remark-vue

npm version npm Build Status Codecov Greenkeeper badge Dependencies devDependencies

Compile Markdown to Vue with remark

📖 Release Notes

Features

remark-vue compiles markdown to Vue. Built on remark, an extensively tested and pluggable parser.

Why? Using domPropsInnerHTML in Vue.js is a common cause of XSS attacks: user input can include script tags and other kinds of active content that reaches across domains and harms security. remark-vue builds a DOM in Vue, using Vue createElement: this means that you can display parsed & formatted Markdown content in an application without using domPropsInnerHTML.

Installation

npm:

npm install remark-vue

Table of Contents

Programmatic

remark.use(vue, options)

Parameters

Let’s say example.js looks as follows:

var Vue = require('vue'),
    remark = require('remark'),
    vueRenderer = require('remark-vue');

var App = new Vue({
  el: '#app',
  data: function () {
    return {
      text: '# hello world'
    }
  },
  onChange(e) {
    this.text = e.target.value;
  },
  render() {
    return (<div>
      <textarea
        value={this.text}
        v-on:change={this.onChange} />
      <div id='preview'>
        { remark().use(vueRenderer).processSync(this.text).contents }
      </div>
    </div>);
  }
});

Configuration

All options, including the options object itself, are optional:

These can passed to remark.use() as a second argument.

Integrations

remark-vue works great with:

All remark nodes can be compiled to HTML.

In addition, remark-vue looks for an attributes object on each node it compiles and adds the found properties as HTML attributes on the compiled tag.

CONTRIBUTING

License

MIT © Titus Wormer, modified by Tom MacWright, Mapbox.

Forked by Med_freeman to remark-vue.