Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 FIX: Ordered list starting number #483

Merged
merged 2 commits into from Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions myst_parser/docutils_renderer.py
Expand Up @@ -377,9 +377,9 @@ 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()
list_node["enumtype"] = "arabic"
list_node["suffix"] = "."
list_node = nodes.enumerated_list(enumtype="arabic", prefix="", suffix=".")
if "start" in token.attrs: # starting number
list_node["start"] = token.attrs["start"]
self.add_line_and_source_path(list_node, token)
with self.current_node_context(list_node, append=True):
self.render_children(token)
Expand Down
20 changes: 17 additions & 3 deletions tests/test_renderers/fixtures/docutil_syntax_elements.md
Expand Up @@ -257,13 +257,27 @@ Nested Bullets
Enumerated List:
.
1. *foo*

para

10. starting
11. enumerator
.
<document source="notset">
<enumerated_list enumtype="arabic" suffix=".">
<enumerated_list enumtype="arabic" prefix="" suffix=".">
<list_item>
<paragraph>
<emphasis>
foo
<paragraph>
para
<enumerated_list enumtype="arabic" prefix="" start="10" suffix=".">
<list_item>
<paragraph>
starting
<list_item>
<paragraph>
enumerator
.

--------------------------
Expand All @@ -274,14 +288,14 @@ Nested Enumrated List:
1. c
.
<document source="notset">
<enumerated_list enumtype="arabic" suffix=".">
<enumerated_list enumtype="arabic" prefix="" suffix=".">
<list_item>
<paragraph>
a
<list_item>
<paragraph>
b
<enumerated_list enumtype="arabic" suffix=".">
<enumerated_list enumtype="arabic" prefix="" suffix=".">
<list_item>
<paragraph>
c
Expand Down
20 changes: 17 additions & 3 deletions tests/test_renderers/fixtures/sphinx_syntax_elements.md
Expand Up @@ -257,13 +257,27 @@ Nested Bullets
Enumerated List:
.
1. *foo*

para

10. starting
11. enumerator
.
<document source="notset">
<enumerated_list enumtype="arabic" suffix=".">
<enumerated_list enumtype="arabic" prefix="" suffix=".">
<list_item>
<paragraph>
<emphasis>
foo
<paragraph>
para
<enumerated_list enumtype="arabic" prefix="" start="10" suffix=".">
<list_item>
<paragraph>
starting
<list_item>
<paragraph>
enumerator
.

--------------------------
Expand All @@ -274,14 +288,14 @@ Nested Enumrated List:
1. c
.
<document source="notset">
<enumerated_list enumtype="arabic" suffix=".">
<enumerated_list enumtype="arabic" prefix="" suffix=".">
<list_item>
<paragraph>
a
<list_item>
<paragraph>
b
<enumerated_list enumtype="arabic" suffix=".">
<enumerated_list enumtype="arabic" prefix="" suffix=".">
<list_item>
<paragraph>
c
Expand Down
3 changes: 3 additions & 0 deletions tests/test_sphinx/conftest.py
Expand Up @@ -78,6 +78,9 @@ def read(
# only regress the inner body, since other sections are non-deterministic
soup = BeautifulSoup(content, "html.parser")
doc_div = soup.findAll("div", {"class": "documentwrapper"})[0]
# pygments 2.11.0 introduces a whitespace tag
for pygment_whitespace in doc_div.select("pre > span.w"):
pygment_whitespace.replace_with(pygment_whitespace.text)
text = doc_div.prettify()
for find, rep in (replace or {}).items():
text = text.replace(find, rep)
Expand Down
Expand Up @@ -24,7 +24,7 @@
texte 5 en
<strong>
gras
<enumerated_list enumtype="arabic" suffix=".">
<enumerated_list enumtype="arabic" prefix="" suffix=".">
<list_item>
<paragraph>
texte 6 en
Expand Down
Expand Up @@ -24,7 +24,7 @@
texte 5 en
<strong>
gras
<enumerated_list enumtype="arabic" suffix=".">
<enumerated_list enumtype="arabic" prefix="" suffix=".">
<list_item>
<paragraph>
texte 6 en
Expand Down
Expand Up @@ -24,7 +24,7 @@
texte 5 en
<strong>
gras
<enumerated_list enumtype="arabic" suffix=".">
<enumerated_list enumtype="arabic" prefix="" suffix=".">
<list_item>
<paragraph>
texte 6 en
Expand Down
Expand Up @@ -24,7 +24,7 @@
texte 5 en
<strong>
gras
<enumerated_list enumtype="arabic" suffix=".">
<enumerated_list enumtype="arabic" prefix="" suffix=".">
<list_item>
<paragraph>
texte 6 en
Expand Down