Fix parsing bug

This commit is contained in:
Brian Buller 2023-09-14 10:01:09 -05:00
parent 3728b9b14f
commit 51323ad5a7
1 changed files with 15 additions and 5 deletions

View File

@ -29,13 +29,11 @@ func ParseProject(text string) (*Project, error) {
//parts := strings.Fields(project.Original) //parts := strings.Fields(project.Original)
var pIdx int var pIdx int
for pIdx = range parts { for pIdx = range parts {
if len(parts[pIdx]) > 0 { if partIsSpecial(parts[pIdx]) {
if parts[pIdx][0] == '^' {
break break
} }
project.Name = project.Name + " " + parts[pIdx] project.Name = project.Name + " " + parts[pIdx]
} }
}
project.Name = strings.TrimSpace(project.Name) project.Name = strings.TrimSpace(project.Name)
parts = parts[pIdx:] parts = parts[pIdx:]
var notesAbs, repoAbs bool var notesAbs, repoAbs bool
@ -81,6 +79,18 @@ func ParseProject(text string) (*Project, error) {
return &project, err return &project, err
} }
func partIsSpecial(pt string) bool {
if len(pt) == 0 {
return false
}
switch pt[0] {
case '^', '~', '#', '@', '+':
return true
default:
return false
}
}
// getParts parses the text from text pulling out each part. // getParts parses the text from text pulling out each part.
// By default it splits on spaces, the only exception is if we find a double-quote // By default it splits on spaces, the only exception is if we find a double-quote
func getParts(text string) []string { func getParts(text string) []string {