mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +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();
|
var m = match[1].trim();
|
||||||
if (m.isNotEmpty) {
|
if (m.isNotEmpty) {
|
||||||
el.attributes['xUpperCase'] = (m[0] == 'X').toString();
|
el.attributes['xUpperCase'] = (m[0] == 'X').toString();
|
||||||
|
} else {
|
||||||
|
el.attributes['xUpperCase'] = "false";
|
||||||
}
|
}
|
||||||
el.attributes['text'] = '${match[2]}';
|
el.attributes['text'] = '${match[2]}';
|
||||||
parser.addNode(el);
|
parser.addNode(el);
|
||||||
@ -259,12 +261,13 @@ class CustomRenderer implements md.NodeVisitor {
|
|||||||
if (tag == 'input') {
|
if (tag == 'input') {
|
||||||
var el = element;
|
var el = element;
|
||||||
if (el is md.Element && el.attributes['type'] == 'checkbox') {
|
if (el is md.Element && el.attributes['type'] == 'checkbox') {
|
||||||
|
assert(el.attributes.containsKey('xUpperCase'));
|
||||||
bool val = el.attributes['checked'] != 'false';
|
bool val = el.attributes['checked'] != 'false';
|
||||||
if (val) {
|
if (val) {
|
||||||
if (el.attributes['xUpperCase'] != 'false') {
|
if (el.attributes['xUpperCase'] != 'false') {
|
||||||
buffer.write('[x] ');
|
|
||||||
} else {
|
|
||||||
buffer.write('[X] ');
|
buffer.write('[X] ');
|
||||||
|
} else {
|
||||||
|
buffer.write('[x] ');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer.write('[ ] ');
|
buffer.write('[ ] ');
|
||||||
|
@ -94,7 +94,7 @@ How are you doing?
|
|||||||
|
|
||||||
[x] item 1
|
[x] item 1
|
||||||
[ ] Foo
|
[ ] Foo
|
||||||
[X] item 3
|
[x] item 3
|
||||||
[ ] item 4
|
[ ] item 4
|
||||||
|
|
||||||
Booga Wooga
|
Booga Wooga
|
||||||
@ -226,5 +226,21 @@ Booga Wooga
|
|||||||
note = checklist.note;
|
note = checklist.note;
|
||||||
expect(note.body, "[ ] One\n[ ]Two\n[ ] Three\n[ ] Four\n[ ] Five\n");
|
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