Skip to content

Commit

Permalink
👌 IMPROVE: Propagate enumerated list suffix (#484)
Browse files Browse the repository at this point in the history
i.e. "." for `1. a` and ")" for `1) a`
  • Loading branch information
chrisjsewell authored Dec 31, 2021
1 parent feff225 commit 885651f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion myst_parser/docutils_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ def render_bullet_list(self, token: SyntaxTreeNode) -> None:
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)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_renderers/fixtures/docutil_syntax_elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ Enumerated List:
.
1. *foo*

1) bar

para

10. starting
Expand All @@ -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=".">
Expand Down
6 changes: 6 additions & 0 deletions tests/test_renderers/fixtures/sphinx_syntax_elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ Enumerated List:
.
1. *foo*

1) bar

para

10. starting
Expand All @@ -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=".">
Expand Down

0 comments on commit 885651f

Please sign in to comment.