function mergeMdWithRuleFile(config) {
  const doc = fs.readFileSync(config.input, { encoding: 'utf8' });
  const rules = doc.match(/\{\{sample-rule:([\S]+)\}\}/g).map((rawToReplace) => ({
    raw: rawToReplace,
    url: rawToReplace.replace(/\{\{sample-rule:([\S]+)\}\}/g, ($0, $1) => {
      return $1;
    })
  }));

  const tasks = rules.map((item) => (
    new Promise((resolve, reject) => {
      fs.readFile(item.url, 'utf8', (err, data) => {
        if (!err) {
          const result = Object.assign({}, item);
          result.content = data;
          resolve(result);
        } else {
          reject(err);
        }
      });
    })
  ));

  // fetch all samples
  return Promise.all(tasks)
    .then((results) => {
      // merge to doc
      let resultDoc = doc;
      results.forEach((item) => {
        const contentToInsert = textTpl.replace('{{url}}', item.url).replace('{{content}}', item.content);
        resultDoc = resultDoc.replace(item.raw, contentToInsert);
      });
      fs.writeFileSync(config.output, resultDoc);
    }, (fail) => {
      console.log('failed to load resource');
      console.log(fail);
      process.exit();
    })
    .catch(e => {
      console.log(e);
      process.exit();
    });
}
@param {*} config
@param {string} config.input input markdown path
@param {string} config.ouput output markdown path