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.
- 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.
If we start with the file
// some file.js
const bold = '**So bold**';
const mdObj = {
a: '# Some h1 header'
};
after running through the babel compiler it becomes:
// compiled/file.js
const bold = '<b>So bold</b>';
const mdObj = {
a: '<h1> Some h1 header</h1>'
};
- Install
babel-plugin-markdown-compiler
from npm
$ npm install --save-dev babel-plugin-markdown-compiler
- In your
.babelrc
file (or insidepackage.json
babel block if you prefer) add
//.babelrc
{
"plugins": ["markdown-compiler"]
}