diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index 5d716a56..e956655c 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -159,8 +159,8 @@ class MarkdownEditor extends React.Component { e.preventDefault() e.stopPropagation() const idMatch = /checkbox-([0-9]+)/ - const checkedMatch = /^\s*>?\s*[+\-*] \[x]/i - const uncheckedMatch = /^\s*>?\s*[+\-*] \[ ]/ + const checkedMatch = /^(\s*>?)*\s*[+\-*] \[x]/i + const uncheckedMatch = /^(\s*>?)*\s*[+\-*] \[ ]/ const checkReplace = /\[x]/i const uncheckReplace = /\[ ]/ if (idMatch.test(e.target.getAttribute('id'))) { diff --git a/browser/components/MarkdownSplitEditor.js b/browser/components/MarkdownSplitEditor.js index 39f98687..2b63d345 100644 --- a/browser/components/MarkdownSplitEditor.js +++ b/browser/components/MarkdownSplitEditor.js @@ -78,8 +78,8 @@ class MarkdownSplitEditor extends React.Component { e.preventDefault() e.stopPropagation() const idMatch = /checkbox-([0-9]+)/ - const checkedMatch = /^\s*>?\s*[+\-*] \[x]/i - const uncheckedMatch = /^\s*>?\s*[+\-*] \[ ]/ + const checkedMatch = /^(\s*>?)*\s*[+\-*] \[x]/i + const uncheckedMatch = /^(\s*>?)*\s*[+\-*] \[ ]/ const checkReplace = /\[x]/i const uncheckReplace = /\[ ]/ if (idMatch.test(e.target.getAttribute('id'))) { diff --git a/browser/lib/getTodoStatus.js b/browser/lib/getTodoStatus.js index 80584d61..8b552109 100644 --- a/browser/lib/getTodoStatus.js +++ b/browser/lib/getTodoStatus.js @@ -4,7 +4,7 @@ export function getTodoStatus (content) { let numberOfCompletedTodo = 0 splitted.forEach((line) => { - const trimmedLine = line.trim().replace(/^>\s*/, '') + const trimmedLine = line.trim().replace(/^(>\s*)*/, '') if (trimmedLine.match(/^[+\-*] \[(\s|x)] ./i)) { numberOfTodo++ } diff --git a/tests/lib/get-todo-status-test.js b/tests/lib/get-todo-status-test.js index 710c7e92..db74ec56 100644 --- a/tests/lib/get-todo-status-test.js +++ b/tests/lib/get-todo-status-test.js @@ -33,7 +33,9 @@ test('getTodoStatus should return a correct hash object', t => { ['> - [ ] a\n- [x] a\n', { total: 2, completed: 1 }], ['> + [ ] a\n+ foo [x]bar a\n', { total: 1, completed: 0 }], ['> - [X] `- [X] a`\n', { total: 1, completed: 1 }], - ['> \t - [X] `- [X] a`\n', { total: 1, completed: 1 }] + ['> \t - [X] `- [X] a`\n', { total: 1, completed: 1 }], + ['> > - [ ] a\n', { total: 1, completed: 0 }], + ['> > > - [ ] a\n- [x] a\n', { total: 2, completed: 1 }] ] testCases.forEach(testCase => {