function parseMd(content) {
  var frontMatters = [];
  var blockCount;
  var preDataIndex;
  var parseBlockDiv;
  var preImgObject = { 'image': {} };
  var isNotFrontMatterCount = 0;
  var isAmpImgRange = false;
  var result = [];

  for (const line of content.split('\n')) {
    if (isNotFrontMatterCount < 2) {
      frontMatters.push(line)
      if (line.includes('---')) {
        isNotFrontMatterCount += 1;
      }
      continue;
    }

    if (isAmpImgRange === true && !(line.includes('</amp-img>'))) {
      imgParamObject = parseAmpImg(line);
      preImgObject.image = { ...preImgObject.image, ...imgParamObject };
      continue;
    }

    if (line.includes('###')) {
      parseBlockDiv = true;
      preDataIndex = 0;
      blockCount = blockCount + 1 | 0;
      const preBlockindex = blockCount;
      const title = parseTitle(line);
      result[preBlockindex] = { title: title };

    } else if (line.includes('amp-img')) {
      const preBlockindex = blockCount;
      if (line.includes('</amp-img>')) {
        addDataToBlockArray(preImgObject, result, preBlockindex, preDataIndex);
        isAmpImgRange = false;
        preImgObject = { 'image': {} }
        preDataIndex += 1;
        continue;
      }
      isAmpImgRange = true;
    } else {
      if (parseBlockDiv === undefined) {
        // for skipping space before first title
        continue
      }
      if (line === '') {
        // for skipping space
        continue
      }
      const preBlockindex = blockCount;
      const ownDataIndex = preDataIndex;
      preDataIndex += 1;
      //addDataToBlockArray({ description: { text: line } }, result, preBlockindex, ownDataIndex);
      addDataToBlockArray({ text: line }, result, preBlockindex, ownDataIndex);
    }
  }
  alert(JSON.stringify(result));
  return { frontMatters: frontMatters, preBlockArray: result }
}

const parseTitle = line => {
  var title = '';
  title = line.replace('### **', '');
  title = title.replace('**', '');
  if (title.includes('敘述')) {
    title = title.replace('<!-- ', '');
    title = title.replace('-->', '');
  }
  return title;
};

const parseAmpImg = line => {
  if (line.includes('alt')) {
    const altParameter = line.replace(/ |alt=|"/g, '');
    return { alt: altParameter };
  } else if (line.includes('src')) {
    const srcParameter = line.replace(/ |src=|"/g, '');
    return { src: srcParameter };
  } else if (line.includes('height')) {
    const heightParameter = line.replace(/ |height=|"/g, '');
    return { height: heightParameter };
  } else if (line.includes('width')) {
    const widthParameter = line.replace(/ |width=|"/g, '');
    return { width: widthParameter };
  } else if (line.includes('layout')) {
    const layoutParameter = line.replace(/ |layout=|"|>/g, '');
  }
}
