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 title = null
|
||||||
let isMarkdownInCode = false
|
let isMarkdownInCode = false
|
||||||
|
|
||||||
for (let i = 0; i < splitted.length; i++) {
|
splitted.some((line, index) => {
|
||||||
let trimmedLine = splitted[i].trim()
|
let trimmedLine = line.trim()
|
||||||
|
let trimmedNextLine = splitted[index + 1] === undefined ? '' : splitted[index + 1].trim()
|
||||||
if (trimmedLine.match('```')) {
|
if (trimmedLine.match('```')) {
|
||||||
isMarkdownInCode = !isMarkdownInCode
|
isMarkdownInCode = !isMarkdownInCode
|
||||||
} else if (isMarkdownInCode === false && trimmedLine.match(/^# +/)) {
|
} else if (isMarkdownInCode === false && (trimmedLine.match(/^# +/) || trimmedNextLine.match('='))) {
|
||||||
title = trimmedLine.substring(1, trimmedLine.length).trim()
|
if (trimmedNextLine.match('=')) {
|
||||||
break
|
title = trimmedLine.substring(0, trimmedLine.length).trim()
|
||||||
|
} else {
|
||||||
|
title = trimmedLine.substring(1, trimmedLine.length).trim()
|
||||||
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
for (let i = 0; i < splitted.length; i++) {
|
for (let i = 0; i < splitted.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user