From 2aea19bd0507e9d02c6b5d3648c8c71a55d37df5 Mon Sep 17 00:00:00 2001 From: "Jocelyn Badgley (Twipped)" Date: Sun, 15 Mar 2020 16:49:03 -0700 Subject: [PATCH] Catching a few more bugs --- build/engines.js | 7 ++++++- build/files.js | 4 ++-- build/lib/markdown-raw-html.js | 10 +++++----- build/page-writer.js | 9 ++++++++- build/page.js | 1 + 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/build/engines.js b/build/engines.js index b6e60af..6ca8b73 100644 --- a/build/engines.js +++ b/build/engines.js @@ -63,7 +63,12 @@ function markdown (mode, input, env) { input = input.replace(//g, ''); } - return input ? markdownEngines[mode].render(input, env) : ''; + try { + return input ? markdownEngines[mode].render(input, env) : ''; + } catch (e) { + log(input); + throw e; + } } function handlebars (input, env) { diff --git a/build/files.js b/build/files.js index d9f4918..564efd1 100644 --- a/build/files.js +++ b/build/files.js @@ -1,5 +1,5 @@ const path = require('path'); -const { groupBy, keyBy, filter, find, get, memoize } = require('lodash'); +const { groupBy, keyBy, filter, find, memoize } = require('lodash'); const { kind, KIND } = require('./resolve'); const File = require('./file'); const Asset = require('./asset'); @@ -22,7 +22,7 @@ module.exports = exports = class Files { this.assets = assets || []; this._getTitlecard = memoize(() => - find(assets, { name: 'titlecard', dir: this.base }) + find(assets, { name: 'titlecard', dir: this.base }), ); this._getWebReady = memoize(() => assets && keyBy(assets.map((a) => a.webready()), 'name')); diff --git a/build/lib/markdown-raw-html.js b/build/lib/markdown-raw-html.js index 63a0b41..d51bbbe 100644 --- a/build/lib/markdown-raw-html.js +++ b/build/lib/markdown-raw-html.js @@ -73,7 +73,7 @@ module.exports = exports = function (md, options) { let token, closeIndex; const tokens = []; const preBlock = openIndex > pos && state.src.slice(pos, openIndex); - debug({ l: 75, preBlock, startLine, lastLine }); + debug({ l: 76, preBlock, startLine, lastLine }); openIndex += fenceLen; pos = openIndex; @@ -90,11 +90,11 @@ module.exports = exports = function (md, options) { } } - debug({ l: 92, tokens }); + debug({ l: 93, tokens }); // find terminating fence if (!scanAhead(state, startLine, pos)) { - debug({ l: 96, remaining: state.src.slice(pos) }); + debug({ l: 97, remaining: state.src.slice(pos) }); // console.error(state.src) throw new Error(`Could not find terminating "${options.fence}" for a raw html block.`); } @@ -163,8 +163,8 @@ module.exports = exports = function (md, options) { startLine = nextLine + 1; endOfLine = state.eMarks[startLine]; - debug({ l: 164, pos, startLine, endOfLine, remaining: state.src.slice(pos) }); - } while (pos + fenceLen < endOfLine); + debug({ l: 164, pos, startLine, endOfLine, remaining: state.src.slice(pos), scan: state.discreteHtmlScan }); + } while (pos < endOfLine && state.discreteHtmlScan.present); if (closer) { state.tokens.push(closer); diff --git a/build/page-writer.js b/build/page-writer.js index 510bde3..a886d89 100644 --- a/build/page-writer.js +++ b/build/page-writer.js @@ -4,6 +4,8 @@ const fs = require('fs-extra'); const { map, uniq } = require('lodash'); const { resolve, ROOT } = require('./resolve'); const { siteInfo } = require(resolve('package.json')); +const log = require('fancy-log'); + module.exports = exports = async function writePageContent (engines, pages, posts, prod) { const postIndex = index(posts, engines); @@ -99,7 +101,12 @@ function processPages (engines, pages, posts, prod) { const state = pageState(page, posts); const json = pageJSON(page); - const html = String(engines[page.engine](page.source, state)); + + try { + var html = String(engines[page.engine](page.source, state)); + } catch (e) { + throw new Error(`Error while processing page "${page.input}": ${e.message}`); + } json.content = page.content; diff --git a/build/page.js b/build/page.js index 7b1f895..d2a384f 100644 --- a/build/page.js +++ b/build/page.js @@ -106,6 +106,7 @@ module.exports = exports = class Page extends File { const { titlecard, webready } = PublicFiles.for(this.dir); this.ignore = this.meta.ignore; this.draft = this.meta.draft; + this.siblings = this.meta.siblings; this.images = webready; this.titlecard = titlecard; if (this.meta.tweets && isString(this.meta.tweets)) this.meta.tweets = this.meta.tweets.split(/\s/);