1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

ignore # in the code block

This commit is contained in:
Sosuke Suzuki
2017-03-17 03:42:17 +09:00
parent 3dc1b59753
commit 034f46792b

View File

@@ -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
}
}
}
}