Repository: executablebooks/MyST-Parser
Pull request #484 (2021-12-31 01:07:02)

👌 IMPROVE: Propagate enumerated list suffix
i.e. "." for `1. a` and ")" for `1) a`

codecov[bot]: # [Codecov](https://codecov.io/gh/executablebooks/MyST-Parser/pull/484?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) Report
> Merging [#484](https://codecov.io/gh/executablebooks/MyST-Parser/pull/484?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) (8865461) into [master](https://codecov.io/gh/executablebooks/MyST-Parser/commit/feff225368a9c66d231ab8ce778e9b81f4dc85f1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) (feff225) will **decrease** coverage by `0.28%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/executablebooks/MyST-Parser/pull/484/graphs/tree.svg?width=650&height=150&src=pr&token=ggpNnuB7ll&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks)](https://codecov.io/gh/executablebooks/MyST-Parser/pull/484?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks)

```diff
@@            Coverage Diff             @@
##           master     #484      +/-   ##
==========================================
- Coverage   90.03%   89.74%   -0.29%     
==========================================
  Files          16       16              
  Lines        2057     2058       +1     
==========================================
- Hits         1852     1847       -5     
- Misses        205      211       +6     
```

| Flag | Coverage Δ | |
|---|---|---|
| pytests | `89.74% <100.00%> (-0.29%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/executablebooks/MyST-Parser/pull/484?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) | Coverage Δ | |
|---|---|---|
| [myst\_parser/docutils\_renderer.py](https://codecov.io/gh/executablebooks/MyST-Parser/pull/484/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#diff-bXlzdF9wYXJzZXIvZG9jdXRpbHNfcmVuZGVyZXIucHk=) | `92.16% <100.00%> (+0.01%)` | :arrow_up: |
| [myst\_parser/mathjax.py](https://codecov.io/gh/executablebooks/MyST-Parser/pull/484/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#diff-bXlzdF9wYXJzZXIvbWF0aGpheC5weQ==) | `82.60% <0.00%> (-13.05%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/executablebooks/MyST-Parser/pull/484?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/executablebooks/MyST-Parser/pull/484?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks). Last update [feff225...8865461](https://codecov.io/gh/executablebooks/MyST-Parser/pull/484?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks).


Patch:
diff --git a/myst_parser/docutils_renderer.py b/myst_parser/docutils_renderer.py
index 3ddb3d9..d247844 100644
--- a/myst_parser/docutils_renderer.py
+++ b/myst_parser/docutils_renderer.py
@@ -377,7 +377,8 @@ class DocutilsRenderer(RendererProtocol):
             self.render_children(token)
 
     def render_ordered_list(self, token: SyntaxTreeNode) -> None:
-        list_node = nodes.enumerated_list(enumtype="arabic", prefix="", suffix=".")
+        list_node = nodes.enumerated_list(enumtype="arabic", prefix="")
+        list_node["suffix"] = token.markup  # for CommonMark, this should be "." or ")"
         if "start" in token.attrs:  # starting number
             list_node["start"] = token.attrs["start"]
         self.add_line_and_source_path(list_node, token)


Test patch:
diff --git a/tests/test_renderers/fixtures/docutil_syntax_elements.md b/tests/test_renderers/fixtures/docutil_syntax_elements.md
index 6e75a8b..8fd4648 100644
--- a/tests/test_renderers/fixtures/docutil_syntax_elements.md
+++ b/tests/test_renderers/fixtures/docutil_syntax_elements.md
@@ -258,6 +258,8 @@ Enumerated List:
 .
 1. *foo*
 
+1) bar
+
 para
 
 10. starting
@@ -269,6 +271,10 @@ para
             <paragraph>
                 <emphasis>
                     foo
+    <enumerated_list enumtype="arabic" prefix="" suffix=")">
+        <list_item>
+            <paragraph>
+                bar
     <paragraph>
         para
     <enumerated_list enumtype="arabic" prefix="" start="10" suffix=".">
diff --git a/tests/test_renderers/fixtures/sphinx_syntax_elements.md b/tests/test_renderers/fixtures/sphinx_syntax_elements.md
index 080913d..0e8cf34 100644
--- a/tests/test_renderers/fixtures/sphinx_syntax_elements.md
+++ b/tests/test_renderers/fixtures/sphinx_syntax_elements.md
@@ -258,6 +258,8 @@ Enumerated List:
 .
 1. *foo*
 
+1) bar
+
 para
 
 10. starting
@@ -269,6 +271,10 @@ para
             <paragraph>
                 <emphasis>
                     foo
+    <enumerated_list enumtype="arabic" prefix="" suffix=")">
+        <list_item>
+            <paragraph>
+                bar
     <paragraph>
         para
     <enumerated_list enumtype="arabic" prefix="" start="10" suffix=".">