fix repTask parsing error and printing error with leading space

This commit is contained in:
Dan Ballard 2018-05-21 14:13:21 -07:00
parent 08624d672c
commit 4204f610a0
5 changed files with 8 additions and 5 deletions

View File

@ -44,7 +44,7 @@ func (ph *processHandler) ProcessLine(line string, indentLevel int, headerStack
// TODO: handle [x] numXnum // TODO: handle [x] numXnum
if !flags.Done || flags.RepTask.Is { if !flags.Done || flags.RepTask.Is {
if flags.RepTask.Is { if flags.RepTask.Is {
ph.Writeln(strings.Repeat("\t", indentLevel) + "- [ ] 0x" + strconv.Itoa(flags.RepTask.B) + lineStack[len(lineStack)-1]) ph.Writeln(strings.Repeat("\t", indentLevel) + "- [ ] 0x" + strconv.Itoa(flags.RepTask.B) + " " + lineStack[len(lineStack)-1])
} else { } else {
ph.Writeln(line) ph.Writeln(line)
} }

View File

@ -39,4 +39,6 @@
# Repetition # Repetition
- [x] 5x5 things - [x] 5x5 things
- [ ] 0x2 other things - [ ] 0x2 other things
- category
- [x] 2x10 nested rep

View File

@ -69,7 +69,7 @@ func (ph *processHandler) ProcessLine(line string, indentLevel int, headerStack
ph.doneCount += 1 ph.doneCount += 1
repStr := "" repStr := ""
if flags.RepTask.Is { if flags.RepTask.Is {
repStr = strconv.Itoa(flags.RepTask.A * flags.RepTask.B) repStr = strconv.Itoa(flags.RepTask.A * flags.RepTask.B) + " "
// inc todo count here since we did a thing, its done, and we dont want a higher done count than total // inc todo count here since we did a thing, its done, and we dont want a higher done count than total
ph.totalCount += 1 ph.totalCount += 1
} }

View File

@ -21,7 +21,8 @@ const EXPECTED = `
a partly done thing / the one done thing a partly done thing / the one done thing
# Repetition # Repetition
25 things 25 things
5 / 15 20 category / nested rep
6 / 16
` `
func TestSummary(t *testing.T) { func TestSummary(t *testing.T) {

View File

@ -148,7 +148,7 @@ func getText(str string, indentLevel int, indentPattern string) (text string, fl
flags.RepTask.A, _ = strconv.Atoi(matches[1]) flags.RepTask.A, _ = strconv.Atoi(matches[1])
flags.RepTask.B, _ = strconv.Atoi(matches[2]) flags.RepTask.B, _ = strconv.Atoi(matches[2])
loc := repTaskRegExp.FindIndex([]byte(text)) loc := repTaskRegExp.FindIndex([]byte(text))
text = text[loc[1]:] text = text[loc[1]+1:]
} }
} }
return return