diff --git a/lib/core/checklist.dart b/lib/core/checklist.dart index c80b3f26..41dacfbf 100644 --- a/lib/core/checklist.dart +++ b/lib/core/checklist.dart @@ -190,6 +190,8 @@ class TaskListSyntax extends md.InlineSyntax { var m = match[1].trim(); if (m.isNotEmpty) { el.attributes['xUpperCase'] = (m[0] == 'X').toString(); + } else { + el.attributes['xUpperCase'] = "false"; } el.attributes['text'] = '${match[2]}'; parser.addNode(el); @@ -259,12 +261,13 @@ class CustomRenderer implements md.NodeVisitor { if (tag == 'input') { var el = element; if (el is md.Element && el.attributes['type'] == 'checkbox') { + assert(el.attributes.containsKey('xUpperCase')); bool val = el.attributes['checked'] != 'false'; if (val) { if (el.attributes['xUpperCase'] != 'false') { - buffer.write('[x] '); - } else { buffer.write('[X] '); + } else { + buffer.write('[x] '); } } else { buffer.write('[ ] '); diff --git a/test/checklist_test.dart b/test/checklist_test.dart index cc24b351..55d54bae 100644 --- a/test/checklist_test.dart +++ b/test/checklist_test.dart @@ -94,7 +94,7 @@ How are you doing? [x] item 1 [ ] Foo -[X] item 3 +[x] item 3 [ ] item 4 Booga Wooga @@ -226,5 +226,21 @@ Booga Wooga note = checklist.note; expect(note.body, "[ ] One\n[ ]Two\n[ ] Three\n[ ] Four\n[ ] Five\n"); }); + + test('Maintain x case', () async { + var content = "[X] One\n[ ]Two"; + + var notePath = p.join(tempDir.path, "note448.md"); + await File(notePath).writeAsString(content); + + var parentFolder = NotesFolderFS(null, tempDir.path); + var note = Note(parentFolder, notePath); + await note.load(); + + var checklist = Checklist(note); + + note = checklist.note; + expect(note.body, content); + }); }); }