1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

front-matter must be delimited by ---

This commit is contained in:
Baptiste Augrain
2018-09-08 10:43:02 +02:00
parent bfd4d7ffe1
commit 90f791de1b
5 changed files with 24 additions and 10 deletions

View File

@@ -0,0 +1,21 @@
'use strict'
module.exports = function frontMatterPlugin (md) {
function frontmatter (state, startLine, endLine, silent) {
if (startLine !== 0 || state.src.substr(startLine, state.eMarks[0]) !== '---') {
return false
}
let line = 0
while (++line < state.lineMax && state.src.substring(state.bMarks[line], state.eMarks[line]) !== '---') {
}
state.line = line + 1
return true
}
md.block.ruler.before('table', 'frontmatter', frontmatter, {
alt: [ 'paragraph', 'reference', 'blockquote', 'list' ]
})
}