add dropped todo items '[-]' and make migrate respect indentPattern
This commit is contained in:
parent
42eb9019d4
commit
b6b6cdcd93
|
@ -58,7 +58,7 @@ The basics of headers with '#'
|
|||
|
||||
Nested lists with '-' for notes and indentation
|
||||
|
||||
Todo and done with '[ ]' and '[x]'
|
||||
Todo and done with '[ ]' for open todo item, '[x]' for done todo item, and '[-]' for dropped todo item
|
||||
|
||||
Obviously you can use other markdown features such as **bold**, *italics* and [Links](https://guides.github.com/features/mastering-markdown/) but none of these trigger any special treatment with regards to Markdown Bullet Journal.
|
||||
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
-
|
||||
asdasd
|
||||
- tabbing
|
||||
- [x] tabs handled
|
||||
- [ ] tabs migrated
|
||||
- [x] tabs handled
|
||||
- [ ] tabs migrated
|
||||
- [-] dropping this task but it's not done
|
||||
- notes
|
||||
|
||||
# Nothing done
|
||||
|
||||
|
@ -39,4 +41,8 @@
|
|||
|
||||
- [ ] not done
|
||||
- [..] partly done
|
||||
- [x...] completed
|
||||
- [X...] completed
|
||||
- [x] completed sub task
|
||||
- notes
|
||||
- more notes
|
||||
- [x] other done task
|
||||
|
|
|
@ -43,7 +43,7 @@ func (ph *processHandler) NewFile() {
|
|||
ph.flagStack = []process.Flags{}
|
||||
}
|
||||
|
||||
func (ph *processHandler) ProcessLine(line string, indentLevel int, headerStack []string, lineStack []string, flags process.Flags) {
|
||||
func (ph *processHandler) ProcessLine(line string, indentLevel int, indentString string, headerStack []string, lineStack []string, flags process.Flags) {
|
||||
if indentLevel+1 > len(ph.flagStack) {
|
||||
ph.flagStack = append(ph.flagStack, flags)
|
||||
} else {
|
||||
|
@ -56,7 +56,7 @@ func (ph *processHandler) ProcessLine(line string, indentLevel int, headerStack
|
|||
if i > indentLevel {
|
||||
break
|
||||
}
|
||||
if iflags.Done {
|
||||
if iflags.Done || iflags.Dropped {
|
||||
print = false
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ func (ph *processHandler) ProcessLine(line string, indentLevel int, headerStack
|
|||
|
||||
if print {
|
||||
if flags.RepTask.Is {
|
||||
ph.Writeln(strings.Repeat("\t", indentLevel) + "- [ ] 0x" + strconv.Itoa(flags.RepTask.B) + " " + lineStack[len(lineStack)-1])
|
||||
ph.Writeln(strings.Repeat(indentString, indentLevel) + "- [ ] 0x" + strconv.Itoa(flags.RepTask.B) + " " + lineStack[len(lineStack)-1])
|
||||
} else if flags.Todo {
|
||||
ph.Writeln(strings.Repeat("\t", indentLevel) + "- [ ] " + lineStack[len(lineStack)-1])
|
||||
ph.Writeln(strings.Repeat(indentString, indentLevel) + "- [ ] " + lineStack[len(lineStack)-1])
|
||||
} else {
|
||||
ph.Writeln(line)
|
||||
}
|
||||
|
|
|
@ -12,19 +12,20 @@ import (
|
|||
const EXPECTED = `# Work
|
||||
|
||||
- [ ] Write tests
|
||||
- [ ] migrate
|
||||
- [ ] migrate
|
||||
|
||||
# Test Data
|
||||
|
||||
- note
|
||||
-
|
||||
- [ ] nesting1
|
||||
- [ ] nesting 2
|
||||
- [ ] nesting 3
|
||||
- [ ] nesting 4
|
||||
- [ ] nesting 2
|
||||
- [ ] nesting 3
|
||||
- [ ] nesting 4
|
||||
- notes of note done thing
|
||||
- tabbing
|
||||
- [ ] tabs migrated
|
||||
- [ ] tabs migrated
|
||||
- notes
|
||||
|
||||
# Nothing done
|
||||
|
||||
|
@ -36,8 +37,8 @@ const EXPECTED = `# Work
|
|||
- [ ] 0x5 things
|
||||
- [ ] 0x2 other things
|
||||
- [ ] Group
|
||||
- [ ] 0x3 nesting rep
|
||||
- [ ] 0x6 done nested rep
|
||||
- [ ] 0x3 nesting rep
|
||||
- [ ] 0x6 done nested rep
|
||||
|
||||
# Pomodoros
|
||||
|
||||
|
@ -75,7 +76,6 @@ func TestMigrate(t *testing.T) {
|
|||
line := strings.Count(string(result[:diffLoc]), "\n")
|
||||
errorStr := string(result[int(math.Max(0, float64(diffLoc - 10))) : int(math.Min(float64(len(result)), float64(diffLoc + 10))) ])
|
||||
|
||||
t.Errorf("Summary results do not match expected:\nfirst difference at line %v: '%v'\n%v<---->\n%v\n", line, errorStr, string(result), EXPECTED)
|
||||
|
||||
t.Errorf("Summary results do not match expected:\nfirst difference at line %v\nexpected char: '%c'\nactual char: '%v'\nline: '%v'\nACTUAL:\n%v<---->\nEXPECTED:\n%v\n", line, EXPECTED[diffLoc], string(result[diffLoc]), errorStr, string(result), EXPECTED)
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ func (ph *processHandler) handleHeaderPrint() {
|
|||
}
|
||||
}
|
||||
|
||||
func (ph *processHandler) ProcessLine(line string, indentLevel int, headerStack []string, lineStack []string, flags process.Flags) {
|
||||
func (ph *processHandler) ProcessLine(line string, indentLevel int, indentString string, headerStack []string, lineStack []string, flags process.Flags) {
|
||||
if strings.Trim(line, " \t\n\r") == "" {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -60,6 +60,6 @@ func TestSummary(t *testing.T) {
|
|||
line := strings.Count(string(result[:diffLoc]), "\n")
|
||||
errorStr := string(result[int(math.Max(0, float64(diffLoc - 10))) : int(math.Min(float64(len(result)), float64(diffLoc + 10))) ])
|
||||
|
||||
t.Errorf("Summary results do not match expected:\nfirst difference at line %v\nexpected char: '%c'\nactual char: '%v'\nline: '%v'\n%v<---->\n%v\n", line, EXPECTED[diffLoc], string(result[diffLoc]), errorStr, string(result), EXPECTED)
|
||||
t.Errorf("Summary results do not match expected:\nfirst difference at line %v\nexpected char: '%c'\nactual char: '%v'\nline: '%v'\nACTUAL:\n%v<---->\nEXPECTED:\n%v\n", line, EXPECTED[diffLoc], string(result[diffLoc]), errorStr, string(result), EXPECTED)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
todoTaskExp = regexp.MustCompile("^\\[([ \\.xX]*)\\]")
|
||||
todoTaskExp = regexp.MustCompile("^\\[([ \\.xX-]*)\\]")
|
||||
startSpaces = regexp.MustCompile("^[\t ]*")
|
||||
repTaskRegExp = regexp.MustCompile("^([0-9]*)[xX]([0-9]*)")
|
||||
headerExp = regexp.MustCompile("^(#+) *(.+)")
|
||||
|
@ -29,13 +29,14 @@ type RepTask struct {
|
|||
type Flags struct {
|
||||
Todo bool
|
||||
Done bool
|
||||
Dropped bool
|
||||
RepTask RepTask
|
||||
Pomodoros int
|
||||
}
|
||||
|
||||
type ProcessHandler interface {
|
||||
Writeln(line string)
|
||||
ProcessLine(line string, indentLevel int, headerStack []string, lineStack []string, flags Flags)
|
||||
ProcessLine(line string, indentLevel int, indentString string, headerStack []string, lineStack []string, flags Flags)
|
||||
Eof()
|
||||
NewFile()
|
||||
}
|
||||
|
@ -124,7 +125,7 @@ func ProcessFile(ph ProcessHandler, fileName string) {
|
|||
lineStack = append(lineStack, row)
|
||||
}
|
||||
|
||||
ph.ProcessLine(line, indentLevel, headerStack, lineStack, flags)
|
||||
ph.ProcessLine(line, indentLevel, indentPattern, headerStack, lineStack, flags)
|
||||
}
|
||||
ph.Eof()
|
||||
}
|
||||
|
@ -132,6 +133,7 @@ func ProcessFile(ph ProcessHandler, fileName string) {
|
|||
func getText(str string, indentLevel int, indentPattern string) (text string, flags Flags) {
|
||||
//fmt.Printf("indentLevel: %v str: '%s'\n", indentLevel, str )
|
||||
flags.Done = false
|
||||
flags.Dropped = false
|
||||
flags.Todo = false
|
||||
flags.RepTask.Is = false
|
||||
flags.Pomodoros = 0
|
||||
|
@ -148,6 +150,9 @@ func getText(str string, indentLevel int, indentPattern string) (text string, fl
|
|||
if strings.ContainsAny(inner, "xX") {
|
||||
flags.Done = true
|
||||
}
|
||||
if strings.Contains(inner, "-") {
|
||||
flags.Dropped = true
|
||||
}
|
||||
flags.Pomodoros = strings.Count(inner, ".")
|
||||
if len(text) > len(inner) + 3 {
|
||||
text = text[len(inner)+3:]
|
||||
|
|
Loading…
Reference in New Issue