Skip to content

Commit b6c777d

Browse files
committed
DOP-2975: Correctly handle non-list elements in list context
1 parent 0bdfdf6 commit b6c777d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

snooty/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ def dispatch_visit(self, node: docutils.nodes.Node) -> None:
205205
util.get_line(node.children[0]),
206206
)
207207
)
208-
raise docutils.nodes.SkipNode()
209208
else:
210209
# Handle case where :field: does not appear in a directive
211210
self.diagnostics.append(
@@ -214,6 +213,7 @@ def dispatch_visit(self, node: docutils.nodes.Node) -> None:
214213
util.get_line(node.children[0]),
215214
)
216215
)
216+
raise docutils.nodes.SkipNode()
217217
elif isinstance(node, docutils.nodes.field_name):
218218
raise docutils.nodes.SkipNode()
219219
elif isinstance(node, docutils.nodes.field_body):

snooty/test_parser.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ def test_codeblock() -> None:
820820
"""
821821
.. code-block:: java
822822
:copyable: false
823-
:source:
823+
:source:
824824
825825
foo""",
826826
)
@@ -3228,3 +3228,23 @@ def test_directive_line_offset() -> None:
32283228
page.finish(diagnostics)
32293229
assert len(diagnostics) == 1
32303230
assert diagnostics[0].start[0] == 13
3231+
3232+
3233+
def test_field_list_in_list() -> None:
3234+
"""Tests DOP-2975"""
3235+
path = ROOT_PATH.joinpath(Path("test.rst"))
3236+
project_config = ProjectConfig(ROOT_PATH, "")
3237+
parser = rstparser.Parser(project_config, JSONVisitor)
3238+
3239+
page, diagnostics = parse_rst(
3240+
parser,
3241+
path,
3242+
r"""
3243+
a. :hash: json
3244+
3245+
#. :hash: json
3246+
""",
3247+
)
3248+
3249+
page.finish(diagnostics)
3250+
assert len(diagnostics) == 2

0 commit comments

Comments
 (0)