mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
ignore # in the code block
This commit is contained in:
@@ -65,12 +65,23 @@ class MarkdownNoteDetail extends React.Component {
|
||||
findTitle (value) {
|
||||
let splitted = value.split('\n')
|
||||
let title = null
|
||||
let markdownInCode = false
|
||||
|
||||
for (let i = 0; i < splitted.length; i++) {
|
||||
let trimmedLine = splitted[i].trim()
|
||||
if (trimmedLine.match(/^# .+/)) {
|
||||
title = trimmedLine.substring(1, trimmedLine.length).trim()
|
||||
break
|
||||
if (trimmedLine.match('```')){
|
||||
if (markdownInCode) {
|
||||
markdownInCode = false
|
||||
} else {
|
||||
markdownInCode = true
|
||||
}
|
||||
} else {
|
||||
if(!markdownInCode) {
|
||||
if (trimmedLine.match(/^# +/)){
|
||||
title = trimmedLine.substring(1, trimmedLine.length).trim()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user