Skip to content

Commit 5ed55d8

Browse files
committed
Don't bail when START, END, or note type are followed by a space
This behavior was very confusing and not communicated to the user, so just allow trailing spaces.
1 parent feb3db2 commit 5ed55d8

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/note.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class Note extends AbstractNote {
135135
}
136136

137137
getNoteType(): string {
138-
return this.split_text[0]
138+
return this.split_text[0].trim()
139139
}
140140

141141
fieldFromLine(line: string): [string, string] {
@@ -204,7 +204,7 @@ export class InlineNote extends AbstractNote {
204204
getNoteType(): string {
205205
const result = this.text.match(InlineNote.TYPE_REGEXP)
206206
this.text = this.text.slice(result.index + result[0].length)
207-
return result[1]
207+
return result[1].trim()
208208
}
209209

210210
getFields(): Record<string, string> {

src/setting-to-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export async function settingToData(app: App, settings: PluginSettings, fields_d
3131
result.FROZEN_REGEXP = new RegExp(escapeRegex(settings.Syntax["Frozen Fields Line"]) + String.raw` - (.*?):\n((?:[^\n][\n]?)+)`, "g")
3232
result.DECK_REGEXP = new RegExp(String.raw`^` + escapeRegex(settings.Syntax["Target Deck Line"]) + String.raw`(?:\n|: )(.*)`, "m")
3333
result.TAG_REGEXP = new RegExp(String.raw`^` + escapeRegex(settings.Syntax["File Tags Line"]) + String.raw`(?:\n|: )(.*)`, "m")
34-
result.NOTE_REGEXP = new RegExp(String.raw`^` + escapeRegex(settings.Syntax["Begin Note"]) + String.raw`\n([\s\S]*?\n)` + escapeRegex(settings.Syntax["End Note"]), "gm")
34+
result.NOTE_REGEXP = new RegExp(String.raw`^` + escapeRegex(settings.Syntax["Begin Note"]) + String.raw`[\s]*\n([\s\S]*?\n)` + escapeRegex(settings.Syntax["End Note"] + "[\s]*"), "gm")
3535
result.INLINE_REGEXP = new RegExp(escapeRegex(settings.Syntax["Begin Inline Note"]) + String.raw`(.*?)` + escapeRegex(settings.Syntax["End Inline Note"]), "g")
3636
result.EMPTY_REGEXP = new RegExp(escapeRegex(settings.Syntax["Delete Note Line"]) + ID_REGEXP_STR, "g")
3737

0 commit comments

Comments
 (0)