0.2.1 • Published 4 years ago

mk2mk v0.2.1

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

Markdown2Markdown Weekly downloads Yearly downloads

Why

Auto generater target markdowns with use of easy template and variable. Good to use with Gatsby or other markdown to html generater.

Recommended For

  • Product Documentation Engineer;
  • Font-end developers who needs markdown transformer

Features

  • Target file auto generate when origin file change;
  • Varible, custom fragments and templates are supported;
  • Path of origin and target is configurable;
  • Files or directories to ignore is configurable;
  • Add custom transform rule is supported;
  • Easy to use for Non-technical User

5min Quick Start

try Demo Repo directely

Examples

  1. use variables;
// origin(src/test.md):
### This is {{var.name}};

// variableFile(src/variables.json)
{"name":"Tom"}

// will turn to target(site/test.md)
### This is Tom;
  1. use fragment and variables;
// origin(src/test.md):
### This is {{var.name}};
{{fragment/card.md}}
{{fragment/warn.md}}

// variableFile (src/variables.json)
{"name":"Tom", "info":{ "phone":"1234567", "email":"xxx@gmail.com"}}

// fragmentFile (src/fragment/card.json)
###### name:{{var.name}}
###### email:{{var.email}}

// fragmentFile (src/fragment/warn.json)
###### the info should keep confidential

// will turn to target(site/test.md)
### This is Tom ;
###### name:Tom
###### email:xxx@gmail.com
###### the info should keep confidential
  1. use multilayer variables
// origin(src/user/info.md):
### This is {{var.name}};
{{fragment/card.md}}
{{fragment/warn.md}}

// variableFile (src/variables.json)
{"name":"Tom", "info":{"phone":"1234567", "email":"xxx@gmail.com"}}

// variableFile (src/user/variables.json)
{"name":"Alex", "info":{"phone":"9876543"}}

// fragmentFile (src/fragment/card.json)
###### name:{{var.name}}
###### email:{{var.email}}

// fragmentFile (src/fragment/warn.json)
###### the info should keep confidential

// will turn to target(site/test.md)
### This is Alex;
###### name:Alex
###### email:xxx@gmail.com
###### the info should keep confidential

API

const {
  setDirWatcher,
  setFileWatcher,
  clearWatcher
} = require("markdown2markdown");

// watch directory configed in m2m.config.js.
const watcher_dir = setDirWatcher();

// watch special file
const watcher_file = setFileWatcher(absolute_path);

// clearWatcher
clearWatcher(watcher_file);

FAQ

Forward

0.2.1

4 years ago