From 38b5a8ec5d09c48fae5a073c1df47a1f66ff20c0 Mon Sep 17 00:00:00 2001 From: Hippo Date: Wed, 1 Jan 2020 21:36:29 +0530 Subject: [PATCH] Medium-to-Ghost processing: Check for title-skipping only once If we've already skipped the title, no need to go on searching for it again. We'll probably end up missing some subheadings or something --- functions.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions.js b/functions.js index 4118a8b..611c460 100644 --- a/functions.js +++ b/functions.js @@ -132,7 +132,7 @@ const pushToGhost = async (postSlug) => { const outStream = fs.createWriteStream(postOutput, { encoding: 'utf-8' }) - let titleSkipped = false; + var titleSkipped = false; let reImage = new RegExp('^!\\[(.*)\\]\\((\\S+?)\\)(.*)') let reTitle = new RegExp('^#\ .*') @@ -144,7 +144,9 @@ const pushToGhost = async (postSlug) => { var newLine = line // Skip the header - if (!titleSkipped && await reTitle.exec(line)) return + if (!titleSkipped && await reTitle.exec(line)) { + titleSkipped = true + } // check for images var m = await reImage.exec(line)