3 Achegas bf5f6c831d ... ebd40b9d77

Autor SHA1 Mensaxe Data
  weichen ebd40b9d77 Merge branch 'master' of http://git.choozmo.com:3000/choozmo/bhouse_backstage %!s(int64=3) %!d(string=hai) anos
  weichen 20aff546e8 add line feed for generating markdown %!s(int64=3) %!d(string=hai) anos
  weichen 981a647a49 parsers change for skipping empty line and fix for parsing title %!s(int64=3) %!d(string=hai) anos
Modificáronse 2 ficheiros con 9 adicións e 5 borrados
  1. 3 3
      backstage/static/js/editor.js
  2. 6 2
      backstage/static/js/parsers.js

+ 3 - 3
backstage/static/js/editor.js

@@ -20,10 +20,10 @@ axios.get(contentApiUrl).then(({ data }) => {
       mdContent += frontMatter + '\n';
     }
     for (var idx=0; idx<blockArray.length; idx++) {
-      mdContent += `\n## **${_.get(blockArray[idx], 'title', '')}**`
+      mdContent += `\n### **${_.get(blockArray[idx], 'title', '')}**\n`
       for (var data of _.get(blockArray[idx], 'data', [])) {
         if (_.get(_.keys(data), 0) === 'description') {
-          mdContent += '\n' + _.get(data, 'description.text', '');
+          mdContent += `\n${_.get(data, 'description.text', '')}`;
         } else if (_.get(_.keys(data), 0) === 'image') {
           ampImgForm = `\n<amp-img\
 \n  alt="${_.get(data, 'image.alt', '小寶優居')}"\
@@ -31,7 +31,7 @@ axios.get(contentApiUrl).then(({ data }) => {
 \n  height="${_.get(data, 'image.height', 300)}"\
 \n  width="${_.get(data, 'image.width', 400)}"\
 \n  layout="${_.get(data, 'image.layout', 'responsive')}">\
-\n</amp-img>`;
+\n</amp-img>\n`;
           mdContent += ampImgForm;
         }
       }

+ 6 - 2
backstage/static/js/parsers.js

@@ -23,7 +23,7 @@ function parseMd(content) {
       continue;
     }
 
-    if (line.includes('##')) {
+    if (line.includes('###')) {
       parseBlockDiv = true;
       preDataIndex = 0;
       blockCount = blockCount + 1 | 0;
@@ -46,6 +46,10 @@ function parseMd(content) {
         // for skipping space before first title
         continue
       }
+      if (line === ''){
+        // for skipping space
+        continue
+      }
       const preBlockindex = blockCount;
       const ownDataIndex = preDataIndex;
       preDataIndex += 1;
@@ -57,7 +61,7 @@ function parseMd(content) {
 
 const parseTitle = line => {
   var title = '';
-  title = line.replace('## **', '');
+  title = line.replace('### **', '');
   title = title.replace('**', '');
   return title;
 };