From f9d5c86245525bee18f5f3c66878fe0a835ec9d0 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Sun, 9 Sep 2018 11:24:54 +0200 Subject: [PATCH] display invalid front-matter --- browser/lib/findNoteTitle.js | 11 +++++++---- browser/lib/markdown-it-frontmatter.js | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/browser/lib/findNoteTitle.js b/browser/lib/findNoteTitle.js index 9dea7b1e..b954f172 100644 --- a/browser/lib/findNoteTitle.js +++ b/browser/lib/findNoteTitle.js @@ -4,11 +4,14 @@ export function findNoteTitle (value) { let isInsideCodeBlock = false if (splitted[0] === '---') { - let index = 0 - while (++index < splitted.length && splitted[index] !== '---') { - } + let line = 0 + while (++line < splitted.length) { + if (splitted[line] === '---') { + splitted.splice(0, line + 1) - splitted.splice(0, index + 1) + break + } + } } splitted.some((line, index) => { diff --git a/browser/lib/markdown-it-frontmatter.js b/browser/lib/markdown-it-frontmatter.js index 051b0bba..66d8ce89 100644 --- a/browser/lib/markdown-it-frontmatter.js +++ b/browser/lib/markdown-it-frontmatter.js @@ -7,12 +7,15 @@ module.exports = function frontMatterPlugin (md) { } let line = 0 - while (++line < state.lineMax && state.src.substring(state.bMarks[line], state.eMarks[line]) !== '---') { + while (++line < state.lineMax) { + if (state.src.substring(state.bMarks[line], state.eMarks[line]) === '---') { + state.line = line + 1 + + return true + } } - state.line = line + 1 - - return true + return false } md.block.ruler.before('table', 'frontmatter', frontmatter, {