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
|
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.
|
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
|
asdasd
|
||||||
- tabbing
|
- tabbing
|
||||||
- [x] tabs handled
|
- [x] tabs handled
|
||||||
- [ ] tabs migrated
|
- [ ] tabs migrated
|
||||||
|
- [-] dropping this task but it's not done
|
||||||
|
- notes
|
||||||
|
|
||||||
# Nothing done
|
# Nothing done
|
||||||
|
|
||||||
|
@ -39,4 +41,8 @@
|
||||||
|
|
||||||
- [ ] not done
|
- [ ] not done
|
||||||
- [..] partly 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{}
|
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) {
|
if indentLevel+1 > len(ph.flagStack) {
|
||||||
ph.flagStack = append(ph.flagStack, flags)
|
ph.flagStack = append(ph.flagStack, flags)
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,7 +56,7 @@ func (ph *processHandler) ProcessLine(line string, indentLevel int, headerStack
|
||||||
if i > indentLevel {
|
if i > indentLevel {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if iflags.Done {
|
if iflags.Done || iflags.Dropped {
|
||||||
print = false
|
print = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,9 @@ func (ph *processHandler) ProcessLine(line string, indentLevel int, headerStack
|
||||||
|
|
||||||
if print {
|
if print {
|
||||||
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(indentString, indentLevel) + "- [ ] 0x" + strconv.Itoa(flags.RepTask.B) + " " + lineStack[len(lineStack)-1])
|
||||||
} else if flags.Todo {
|
} 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 {
|
} else {
|
||||||
ph.Writeln(line)
|
ph.Writeln(line)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,19 +12,20 @@ import (
|
||||||
const EXPECTED = `# Work
|
const EXPECTED = `# Work
|
||||||
|
|
||||||
- [ ] Write tests
|
- [ ] Write tests
|
||||||
- [ ] migrate
|
- [ ] migrate
|
||||||
|
|
||||||
# Test Data
|
# Test Data
|
||||||
|
|
||||||
- note
|
- note
|
||||||
-
|
-
|
||||||
- [ ] nesting1
|
- [ ] nesting1
|
||||||
- [ ] nesting 2
|
- [ ] nesting 2
|
||||||
- [ ] nesting 3
|
- [ ] nesting 3
|
||||||
- [ ] nesting 4
|
- [ ] nesting 4
|
||||||
- notes of note done thing
|
- notes of note done thing
|
||||||
- tabbing
|
- tabbing
|
||||||
- [ ] tabs migrated
|
- [ ] tabs migrated
|
||||||
|
- notes
|
||||||
|
|
||||||
# Nothing done
|
# Nothing done
|
||||||
|
|
||||||
|
@ -36,8 +37,8 @@ const EXPECTED = `# Work
|
||||||
- [ ] 0x5 things
|
- [ ] 0x5 things
|
||||||
- [ ] 0x2 other things
|
- [ ] 0x2 other things
|
||||||
- [ ] Group
|
- [ ] Group
|
||||||
- [ ] 0x3 nesting rep
|
- [ ] 0x3 nesting rep
|
||||||
- [ ] 0x6 done nested rep
|
- [ ] 0x6 done nested rep
|
||||||
|
|
||||||
# Pomodoros
|
# Pomodoros
|
||||||
|
|
||||||
|
@ -75,7 +76,6 @@ func TestMigrate(t *testing.T) {
|
||||||
line := strings.Count(string(result[:diffLoc]), "\n")
|
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))) ])
|
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") == "" {
|
if strings.Trim(line, " \t\n\r") == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,6 @@ func TestSummary(t *testing.T) {
|
||||||
line := strings.Count(string(result[:diffLoc]), "\n")
|
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))) ])
|
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 (
|
var (
|
||||||
todoTaskExp = regexp.MustCompile("^\\[([ \\.xX]*)\\]")
|
todoTaskExp = regexp.MustCompile("^\\[([ \\.xX-]*)\\]")
|
||||||
startSpaces = regexp.MustCompile("^[\t ]*")
|
startSpaces = regexp.MustCompile("^[\t ]*")
|
||||||
repTaskRegExp = regexp.MustCompile("^([0-9]*)[xX]([0-9]*)")
|
repTaskRegExp = regexp.MustCompile("^([0-9]*)[xX]([0-9]*)")
|
||||||
headerExp = regexp.MustCompile("^(#+) *(.+)")
|
headerExp = regexp.MustCompile("^(#+) *(.+)")
|
||||||
|
@ -29,13 +29,14 @@ type RepTask struct {
|
||||||
type Flags struct {
|
type Flags struct {
|
||||||
Todo bool
|
Todo bool
|
||||||
Done bool
|
Done bool
|
||||||
|
Dropped bool
|
||||||
RepTask RepTask
|
RepTask RepTask
|
||||||
Pomodoros int
|
Pomodoros int
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProcessHandler interface {
|
type ProcessHandler interface {
|
||||||
Writeln(line string)
|
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()
|
Eof()
|
||||||
NewFile()
|
NewFile()
|
||||||
}
|
}
|
||||||
|
@ -124,7 +125,7 @@ func ProcessFile(ph ProcessHandler, fileName string) {
|
||||||
lineStack = append(lineStack, row)
|
lineStack = append(lineStack, row)
|
||||||
}
|
}
|
||||||
|
|
||||||
ph.ProcessLine(line, indentLevel, headerStack, lineStack, flags)
|
ph.ProcessLine(line, indentLevel, indentPattern, headerStack, lineStack, flags)
|
||||||
}
|
}
|
||||||
ph.Eof()
|
ph.Eof()
|
||||||
}
|
}
|
||||||
|
@ -132,6 +133,7 @@ func ProcessFile(ph ProcessHandler, fileName string) {
|
||||||
func getText(str string, indentLevel int, indentPattern string) (text string, flags Flags) {
|
func getText(str string, indentLevel int, indentPattern string) (text string, flags Flags) {
|
||||||
//fmt.Printf("indentLevel: %v str: '%s'\n", indentLevel, str )
|
//fmt.Printf("indentLevel: %v str: '%s'\n", indentLevel, str )
|
||||||
flags.Done = false
|
flags.Done = false
|
||||||
|
flags.Dropped = false
|
||||||
flags.Todo = false
|
flags.Todo = false
|
||||||
flags.RepTask.Is = false
|
flags.RepTask.Is = false
|
||||||
flags.Pomodoros = 0
|
flags.Pomodoros = 0
|
||||||
|
@ -148,6 +150,9 @@ func getText(str string, indentLevel int, indentPattern string) (text string, fl
|
||||||
if strings.ContainsAny(inner, "xX") {
|
if strings.ContainsAny(inner, "xX") {
|
||||||
flags.Done = true
|
flags.Done = true
|
||||||
}
|
}
|
||||||
|
if strings.Contains(inner, "-") {
|
||||||
|
flags.Dropped = true
|
||||||
|
}
|
||||||
flags.Pomodoros = strings.Count(inner, ".")
|
flags.Pomodoros = strings.Count(inner, ".")
|
||||||
if len(text) > len(inner) + 3 {
|
if len(text) > len(inner) + 3 {
|
||||||
text = text[len(inner)+3:]
|
text = text[len(inner)+3:]
|
||||||
|
|
Loading…
Reference in New Issue