Skip to content

Commit

Permalink
馃憣 Add myst_enable_checkboxes config (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Jan 17, 2023
1 parent 2764cd2 commit c31ea80
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
myst_heading_anchors = 2
myst_footnote_transition = True
myst_dmath_double_inline = True
myst_enable_checkboxes = True

# -- HTML output -------------------------------------------------

Expand Down
9 changes: 9 additions & 0 deletions myst_parser/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,15 @@ class MdParserConfig:
},
)

enable_checkboxes: bool = dc.field(
default=False,
metadata={
"validator": instance_of(bool),
"help": "Enable checkboxes",
"extension": "tasklist",
},
)

# docutils only (replicating aspects of sphinx config)

suppress_warnings: Sequence[str] = dc.field(
Expand Down
4 changes: 2 additions & 2 deletions myst_parser/parsers/mdit.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def create_md_parser(
# note, strikethrough currently only supported tentatively for HTML
.enable("strikethrough")
.enable("table")
.use(tasklists_plugin)
.use(tasklists_plugin, enabled=config.enable_checkboxes)
.enable("linkify")
.use(wordcount_plugin, per_minute=config.words_per_minute)
)
Expand Down Expand Up @@ -98,7 +98,7 @@ def create_md_parser(
if "fieldlist" in config.enable_extensions:
md.use(fieldlist_plugin)
if "tasklist" in config.enable_extensions:
md.use(tasklists_plugin)
md.use(tasklists_plugin, enabled=config.enable_checkboxes)
if "substitution" in config.enable_extensions:
md.use(substitution_plugin, *config.sub_delimiters)
if "attrs_inline" in config.enable_extensions:
Expand Down
19 changes: 19 additions & 0 deletions tests/test_renderers/fixtures/myst-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,25 @@ www.commonmark.org/he<lp
<lp
.

[tasklist] --myst-enable-extensions=tasklist --myst-enable-checkboxes="true"
.
- [ ] a
- [x] b
.
<document source="<string>">
<bullet_list bullet="-" classes="contains-task-list">
<list_item classes="task-list-item enabled">
<paragraph>
<raw format="html" xml:space="preserve">
<input class="task-list-item-checkbox" type="checkbox">
a
<list_item classes="task-list-item enabled">
<paragraph>
<raw format="html" xml:space="preserve">
<input class="task-list-item-checkbox" checked="checked" type="checkbox">
b
.

[heading_anchors] --myst-heading-anchors=1
.
# My title
Expand Down

0 comments on commit c31ea80

Please sign in to comment.