From 3942e894cf008873ffa222dacb6338aa40b5930a Mon Sep 17 00:00:00 2001 From: Adrian Phinney Date: Thu, 19 Nov 2020 09:30:04 -0500 Subject: [PATCH] fix: task lists not rendered when GFM is disabled (#1825) * Fix #1823 - task lists are rendered even when GFM is disabled. * end file with a new line Co-authored-by: Tony Brix --- src/Tokenizer.js | 12 +++++++----- test/specs/new/list_tasks_non_gfm.html | 5 +++++ test/specs/new/list_tasks_non_gfm.md | 7 +++++++ 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 test/specs/new/list_tasks_non_gfm.html create mode 100644 test/specs/new/list_tasks_non_gfm.md diff --git a/src/Tokenizer.js b/src/Tokenizer.js index e7d71fe027..20f122332f 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -278,11 +278,13 @@ module.exports = class Tokenizer { } // Check for task list items - istask = /^\[[ xX]\] /.test(item); - ischecked = undefined; - if (istask) { - ischecked = item[1] !== ' '; - item = item.replace(/^\[[ xX]\] +/, ''); + if (this.options.gfm) { + istask = /^\[[ xX]\] /.test(item); + ischecked = undefined; + if (istask) { + ischecked = item[1] !== ' '; + item = item.replace(/^\[[ xX]\] +/, ''); + } } list.items.push({ diff --git a/test/specs/new/list_tasks_non_gfm.html b/test/specs/new/list_tasks_non_gfm.html new file mode 100644 index 0000000000..dfa23220e1 --- /dev/null +++ b/test/specs/new/list_tasks_non_gfm.html @@ -0,0 +1,5 @@ + diff --git a/test/specs/new/list_tasks_non_gfm.md b/test/specs/new/list_tasks_non_gfm.md new file mode 100644 index 0000000000..b75875a679 --- /dev/null +++ b/test/specs/new/list_tasks_non_gfm.md @@ -0,0 +1,7 @@ +--- +gfm: false +description: Task lists are ignored when not using GFM +--- +- [ ] A +- [x] B +- [ ] C \ No newline at end of file