Skip to content

Commit a74a078

Browse files
authored
Support ol start attribute (#175)
1 parent ff45dea commit a74a078

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- fail_on_diagnostics toml flag (DOP-1132)
1313
- Support additional ordered list labels (DOP-1129)
14+
- Support ordered list "start" attribute (DOP-1210)
1415

1516
## [v0.4.11] - 2020-06-22
1617

snooty/n.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ class ListNodeItem(Parent[Node]):
233233

234234
@dataclass
235235
class ListNode(Parent[ListNodeItem]):
236-
__slots__ = "enumtype"
236+
__slots__ = ("enumtype", "startat")
237237
type = "list"
238238
enumtype: ListEnumType
239+
startat: Optional[int]
239240

240241

241242
@dataclass

snooty/parser.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,16 @@ def dispatch_visit(self, node: docutils.nodes.Node) -> None:
234234
elif isinstance(node, docutils.nodes.definition_list_item):
235235
self.state.append(n.DefinitionListItem((line,), [], []))
236236
elif isinstance(node, docutils.nodes.bullet_list):
237-
self.state.append(n.ListNode((line,), [], n.ListEnumType.unordered))
237+
self.state.append(n.ListNode((line,), [], n.ListEnumType.unordered, None))
238238
elif isinstance(node, docutils.nodes.enumerated_list):
239-
self.state.append(n.ListNode((line,), [], n.ListEnumType[node["enumtype"]]))
239+
self.state.append(
240+
n.ListNode(
241+
(line,),
242+
[],
243+
n.ListEnumType[node["enumtype"]],
244+
node["start"] if "start" in node else None,
245+
)
246+
)
240247
elif isinstance(node, docutils.nodes.list_item):
241248
self.state.append(n.ListNodeItem((line,), []))
242249
elif isinstance(node, docutils.nodes.title):

snooty/test_parser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,10 @@ def test_list() -> None:
10731073
a. First list item
10741074
#. Second
10751075
#. Third
1076+
1077+
e. Fifth list item
1078+
#. Sixth
1079+
#. Seventh
10761080
""",
10771081
)
10781082
page.finish(diagnostics)
@@ -1085,6 +1089,11 @@ def test_list() -> None:
10851089
<listItem><paragraph><text>Second</text></paragraph></listItem>
10861090
<listItem><paragraph><text>Third</text></paragraph></listItem>
10871091
</list>
1092+
<list enumtype="loweralpha" startat="5">
1093+
<listItem><paragraph><text>Fifth list item</text></paragraph></listItem>
1094+
<listItem><paragraph><text>Sixth</text></paragraph></listItem>
1095+
<listItem><paragraph><text>Seventh</text></paragraph></listItem>
1096+
</list>
10881097
</root>""",
10891098
)
10901099

0 commit comments

Comments
 (0)