Skip to content

Commit 54de57e

Browse files
authored
Merge pull request #2863 from zzdjk6/master
FIX #2853 Allow "#" in title
2 parents 53ff693 + 0f232b3 commit 54de57e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

browser/lib/markdownTextHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function strip (input) {
2222
.replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '$1')
2323
.replace(/>/g, '')
2424
.replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, '')
25-
.replace(/^#{1,6}\s*([^#]*)\s*(#{1,6})?/gm, '$1')
25+
.replace(/^#{1,6}\s*/gm, '')
2626
.replace(/(`{3,})(.*?)\1/gm, '$2')
2727
.replace(/^-{3,}\s*$/g, '')
2828
.replace(/`(.+?)`/g, '$1')

browser/main/Detail/MarkdownNoteDetail.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ class MarkdownNoteDetail extends React.Component {
100100
handleUpdateContent () {
101101
const { note } = this.state
102102
note.content = this.refs.content.value
103-
note.title = markdown.strip(striptags(findNoteTitle(note.content, this.props.config.editor.enableFrontMatterTitle, this.props.config.editor.frontMatterTitleField)))
103+
104+
let title = findNoteTitle(note.content, this.props.config.editor.enableFrontMatterTitle, this.props.config.editor.frontMatterTitleField)
105+
title = striptags(title)
106+
title = markdown.strip(title)
107+
note.title = title
108+
104109
this.updateNote(note)
105110
}
106111

tests/lib/markdown-text-helper-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ test(t => {
3636
['`MY_TITLE`', 'MY_TITLE'],
3737
['MY_TITLE', 'MY_TITLE'],
3838
// I have no idea for it...
39-
['```test', '`test']
39+
['```test', '`test'],
40+
['# C# Features', 'C# Features']
4041
]
4142

4243
testCases.forEach(testCase => {

0 commit comments

Comments
 (0)