mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-12 17:26:17 +00:00
Edit the method
This commit is contained in:
@@ -3,18 +3,22 @@ export function findNoteTitle (value) {
|
||||
let title = null
|
||||
let isMarkdownInCode = false
|
||||
|
||||
for (let i = 0; i < splitted.length; i++) {
|
||||
let trimmedLine = splitted[i].trim()
|
||||
splitted.some((line, index) => {
|
||||
let trimmedLine = line.trim()
|
||||
let trimmedNextLine = splitted[index + 1] === undefined ? '' : splitted[index + 1].trim()
|
||||
if (trimmedLine.match('```')) {
|
||||
isMarkdownInCode = !isMarkdownInCode
|
||||
} else if (isMarkdownInCode === false && trimmedLine.match(/^# +/)) {
|
||||
title = trimmedLine.substring(1, trimmedLine.length).trim()
|
||||
break
|
||||
} else if (isMarkdownInCode === false && (trimmedLine.match(/^# +/) || trimmedNextLine.match('='))) {
|
||||
if (trimmedNextLine.match('=')) {
|
||||
title = trimmedLine.substring(0, trimmedLine.length).trim()
|
||||
} else {
|
||||
title = trimmedLine.substring(1, trimmedLine.length).trim()
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (title === null) {
|
||||
title = ''
|
||||
if (title == null) {
|
||||
for (let i = 0; i < splitted.length; i++) {
|
||||
let trimmedLine = splitted[i].trim()
|
||||
if (trimmedLine.length > 0) {
|
||||
@@ -22,6 +26,9 @@ export function findNoteTitle (value) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if (title == null) {
|
||||
title = ''
|
||||
}
|
||||
}
|
||||
|
||||
return title
|
||||
|
||||
Reference in New Issue
Block a user