项目作者: inakianduaga

项目描述 :
Compile markdown inside object literals
高级语言: JavaScript
项目地址: git://github.com/inakianduaga/babel-plugin-markdown-compiler.git
创建时间: 2015-12-21T20:54:57Z
项目社区:https://github.com/inakianduaga/babel-plugin-markdown-compiler

开源协议:MIT License

下载


babel-plugin-markdown-compiler

Compile markdown inside object literals

The target of this plugin is to provide markdown compilation of static strings inside objects / variables in your application during compilation time.
It came as a necessity to support markdown inside typescript language files.

Features:

  • Compiles markdown inside object literals using Markdown-It;
  • Parse static markdown inside your app on compile time instead of runtime, increasing performance and reducing production dependencies.

Example:

If we start with the file

  1. // some file.js
  2. const bold = '**So bold**';
  3. const mdObj = {
  4. a: '# Some h1 header'
  5. };

after running through the babel compiler it becomes:

  1. // compiled/file.js
  2. const bold = '<b>So bold</b>';
  3. const mdObj = {
  4. a: '<h1> Some h1 header</h1>'
  5. };

Usage:

  1. Install babel-plugin-markdown-compiler from npm
  1. $ npm install --save-dev babel-plugin-markdown-compiler
  1. In your .babelrc file (or inside package.json babel block if you prefer) add
  1. //.babelrc
  2. {
  3. "plugins": ["markdown-compiler"]
  4. }