Skip to content

Commit df14c91

Browse files
committed
✨ NEW: Add myst_commonmark_only config option
1 parent 8206f2a commit df14c91

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

docs/develop/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ For code tests, myst-parser uses [pytest](https://docs.pytest.org)):
5959
You can also use [tox](https://tox.readthedocs.io), to run the tests in multiple isolated environments (see the `tox.ini` file for available test environments):
6060

6161
```shell
62-
>> cd markdown-it-py
62+
>> cd MyST-Parser
6363
>> tox
6464
```
6565

docs/using/intro.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Once you've enabled the `myst-parser` in Sphinx, it will be able to parse your M
8080
markdown documents. This means that you can use the `.md` extension for your pages,
8181
and write MyST markdown in these pages.
8282

83-
:::{tip}
83+
:::{note}
8484
MyST markdown is a mixture of two flavors of markdown:
8585

8686
It supports all the syntax of **[CommonMark Markdown](https://commonmark.org/)** at its
@@ -91,6 +91,10 @@ In addition, it includes **several extensions to CommonMark**
9191
designed to work with the Sphinx ecosystem (and inspired by reStructuredText)
9292
:::
9393

94+
:::{tip}
95+
If you want to parse your files as only **strict** CommonMark (no extensions), then you can set the `conf.py` option `myst_commonmark_only=True`.
96+
:::
97+
9498
The following sections cover a few core syntax patterns in MyST markdown, you can
9599
find a more exhaustive list in {doc}`syntax`.
96100

@@ -219,6 +223,9 @@ To do so, use the keywords beginning `myst_`.
219223
* - Option
220224
- Default
221225
- Description
226+
* - `myst_commonmark_only`
227+
- `False`
228+
- If `True` convert text as strict CommonMark (all options below are then ignored)
222229
* - `myst_disable_syntax`
223230
- ()
224231
- List of markdown syntax elements to disable, see the [markdown-it parser guide](markdown_it:using).

myst_parser/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class MdParserConfig:
2828
renderer: str = attr.ib(
2929
default="sphinx", validator=in_(["sphinx", "html", "docutils"])
3030
)
31+
commonmark_only: bool = attr.ib(default=False, validator=instance_of(bool))
3132
dmath_enable: bool = attr.ib(default=True, validator=instance_of(bool))
3233
dmath_allow_labels: bool = attr.ib(default=True, validator=instance_of(bool))
3334
dmath_allow_space: bool = attr.ib(default=True, validator=instance_of(bool))
@@ -70,6 +71,9 @@ def default_parser(config: MdParserConfig) -> MarkdownIt:
7071
else:
7172
raise ValueError("unknown renderer type: {0}".format(config.renderer))
7273

74+
if config.commonmark_only:
75+
return MarkdownIt("commonmark", renderer_cls=renderer_cls)
76+
7377
md = (
7478
MarkdownIt("commonmark", renderer_cls=renderer_cls)
7579
.enable("table")

0 commit comments

Comments
 (0)