Skip to content

Commit f1c182c

Browse files
committed
fix: parser regressions with multiple pipes and priority suffixes
1 parent 011e28e commit f1c182c

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

internal/parser.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ func ParseEntry(args []string) model.Entry {
2121
fullInput = strings.TrimSpace(fullInput)
2222
}
2323

24-
parts := strings.SplitN(fullInput, "|", 2)
24+
lastPipe := strings.LastIndex(fullInput, "|")
2525
var contentPart string
26-
27-
if len(parts) == 2 {
28-
entry.MarginKey = strings.TrimSpace(parts[0])
29-
contentPart = strings.TrimSpace(parts[1])
26+
if lastPipe != -1 {
27+
entry.MarginKey = strings.TrimSpace(fullInput[:lastPipe])
28+
contentPart = strings.TrimSpace(fullInput[lastPipe+1:])
3029
} else {
31-
contentPart = strings.TrimSpace(parts[0])
30+
contentPart = strings.TrimSpace(fullInput)
3231
}
3332

3433
// Detect bullet types

internal/parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestParseEntry(t *testing.T) {
2424
args: []string{"IDEAS", "|", "-", "Priority note!"},
2525
wantMK: "IDEAS",
2626
wantBlt: "-",
27-
wantCnt: "Priority note!",
27+
wantCnt: "Priority note",
2828
},
2929
{
3030
name: "No margin key",

0 commit comments

Comments
 (0)