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
This commit is contained in:
Hippo 2020-01-01 21:36:29 +05:30
parent 2131d76fd5
commit 38b5a8ec5d

View file

@ -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)