-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ignore # in the code block #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| findTitle (value) { | ||
| let splitted = value.split('\n') | ||
| let title = null | ||
| let markdownInCode = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codeBlockInMarkdown, isCodeBlockInMarkdown or isCodeBlockInNote?
| markdownInCode = false | ||
| } else { | ||
| markdownInCode = true | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
markdownInCode = !markdownInCode looks better for me.
if (trimmedLine.match('```')){
markdownInCode = !markdownInCode
}
| title = trimmedLine.substring(1, trimmedLine.length).trim() | ||
| break | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you can make this if clause better. Like below:
if(markdownInCode === false && trimmendLine.match(/^# +/)){
title = trimmedLine.substring(1, trimmedLine.length).trim()
break
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for correcting my code. I think that it is readble than my code. I'll rewrite it.
| title = trimmedLine.substring(1, trimmedLine.length).trim() | ||
| break | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for corrections! And I recognized 1 point. You can reduce 1 indent like this below:
if (trimmedLine.match('```')){
isMarkdownInCode = !isMarkdownInCode
} else if(isMarkdownInCode === false && trimmedLine.match(/^# +/)) {
title = trimmedLine.substring(1, trimmedLine.length).trim()
break
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your advice ! I will fix it soon.
| break | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code doesn't work. Because there is an extra }. And also the indents are not good 😨
if (trimmedLine.match('```')){
isMarkdownInCode = !isMarkdownInCode
} else if (isMarkdownInCode === false && trimmedLine.match(/^# +/)) {
title = trimmedLine.substring(1, trimmedLine.length).trim()
break
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'll fix it soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

I solved the issue.
Before
Previously, a character string beginning with '#' in the code block was treated as the title of the markdown note.

After
Currently, strings beginning with '#' in the code block are ignored.
