mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
front-matter must be delimited by ---
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
const frontMatterRegex = /^\-{3,}/
|
||||
|
||||
export function findNoteTitle (value) {
|
||||
const splitted = value.split('\n')
|
||||
let title = null
|
||||
let isInsideCodeBlock = false
|
||||
|
||||
if (frontMatterRegex.exec(splitted[0])) {
|
||||
if (splitted[0] === '---') {
|
||||
let index = 0
|
||||
while (++index < splitted.length && !frontMatterRegex.exec(splitted[index])) {
|
||||
while (++index < splitted.length && splitted[index] !== '---') {
|
||||
}
|
||||
|
||||
splitted.splice(0, index + 1)
|
||||
|
||||
21
browser/lib/markdown-it-frontmatter.js
Normal file
21
browser/lib/markdown-it-frontmatter.js
Normal 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' ]
|
||||
})
|
||||
}
|
||||
@@ -149,7 +149,7 @@ class Markdown {
|
||||
})
|
||||
this.md.use(require('markdown-it-kbd'))
|
||||
this.md.use(require('markdown-it-admonition'))
|
||||
this.md.use(require('markdown-it-front-matter'), fm => {})
|
||||
this.md.use(require('./markdown-it-frontmatter'))
|
||||
|
||||
const deflate = require('markdown-it-plantuml/lib/deflate')
|
||||
this.md.use(require('markdown-it-plantuml'), '', {
|
||||
|
||||
@@ -74,7 +74,6 @@
|
||||
"markdown-it-admonition": "^1.0.4",
|
||||
"markdown-it-emoji": "^1.1.1",
|
||||
"markdown-it-footnote": "^3.0.0",
|
||||
"markdown-it-front-matter": "^0.1.2",
|
||||
"markdown-it-imsize": "^2.0.1",
|
||||
"markdown-it-kbd": "^1.1.1",
|
||||
"markdown-it-multimd-table": "^2.0.1",
|
||||
|
||||
@@ -5735,10 +5735,6 @@ markdown-it-footnote@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it-footnote/-/markdown-it-footnote-3.0.1.tgz#7f3730747cacc86e2fe0bf8a17a710f34791517a"
|
||||
|
||||
markdown-it-front-matter@^0.1.2:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it-front-matter/-/markdown-it-front-matter-0.1.2.tgz#e50bf56e77e6a4f5ac4ffa894d4d45ccd9896b20"
|
||||
|
||||
markdown-it-imsize@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it-imsize/-/markdown-it-imsize-2.0.1.tgz#cca0427905d05338a247cb9ca9d968c5cddd5170"
|
||||
|
||||
Reference in New Issue
Block a user