mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 09:47:35 +08:00
Checklist: Maintain the case of 'x'
This commit is contained in:
@ -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('[ ] ');
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user