mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
Merge pull request #510 from BoostIO/fix-note-title-bug-for-h1
fix the bug when using markdown syntax h1
This commit is contained in:
@@ -68,15 +68,20 @@ class MarkdownNoteDetail extends React.Component {
|
||||
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(/^# +/)) {
|
||||
} 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()
|
||||
break
|
||||
}
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
if (title == null) {
|
||||
for (let i = 0; i < splitted.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user