Skip to content

Commit c31ea80

Browse files
authored
👌 Add myst_enable_checkboxes config (#686)
1 parent 2764cd2 commit c31ea80

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
myst_heading_anchors = 2
107107
myst_footnote_transition = True
108108
myst_dmath_double_inline = True
109+
myst_enable_checkboxes = True
109110

110111
# -- HTML output -------------------------------------------------
111112

myst_parser/config/main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ class MdParserConfig:
300300
},
301301
)
302302

303+
enable_checkboxes: bool = dc.field(
304+
default=False,
305+
metadata={
306+
"validator": instance_of(bool),
307+
"help": "Enable checkboxes",
308+
"extension": "tasklist",
309+
},
310+
)
311+
303312
# docutils only (replicating aspects of sphinx config)
304313

305314
suppress_warnings: Sequence[str] = dc.field(

myst_parser/parsers/mdit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def create_md_parser(
4848
# note, strikethrough currently only supported tentatively for HTML
4949
.enable("strikethrough")
5050
.enable("table")
51-
.use(tasklists_plugin)
51+
.use(tasklists_plugin, enabled=config.enable_checkboxes)
5252
.enable("linkify")
5353
.use(wordcount_plugin, per_minute=config.words_per_minute)
5454
)
@@ -98,7 +98,7 @@ def create_md_parser(
9898
if "fieldlist" in config.enable_extensions:
9999
md.use(fieldlist_plugin)
100100
if "tasklist" in config.enable_extensions:
101-
md.use(tasklists_plugin)
101+
md.use(tasklists_plugin, enabled=config.enable_checkboxes)
102102
if "substitution" in config.enable_extensions:
103103
md.use(substitution_plugin, *config.sub_delimiters)
104104
if "attrs_inline" in config.enable_extensions:

tests/test_renderers/fixtures/myst-config.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ www.commonmark.org/he<lp
156156
<lp
157157
.
158158

159+
[tasklist] --myst-enable-extensions=tasklist --myst-enable-checkboxes="true"
160+
.
161+
- [ ] a
162+
- [x] b
163+
.
164+
<document source="<string>">
165+
<bullet_list bullet="-" classes="contains-task-list">
166+
<list_item classes="task-list-item enabled">
167+
<paragraph>
168+
<raw format="html" xml:space="preserve">
169+
<input class="task-list-item-checkbox" type="checkbox">
170+
a
171+
<list_item classes="task-list-item enabled">
172+
<paragraph>
173+
<raw format="html" xml:space="preserve">
174+
<input class="task-list-item-checkbox" checked="checked" type="checkbox">
175+
b
176+
.
177+
159178
[heading_anchors] --myst-heading-anchors=1
160179
.
161180
# My title

0 commit comments

Comments
 (0)