Skip to content

Commit 518583c

Browse files
committed
DOP-1056: Don't pop the top node on the stack upon InvalidURL
1 parent 4d8cfa3 commit 518583c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

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

1212
- Support for links in step file headings (DOP-1015).
13+
- Incorrect AST output with hyperlink references (DOP-1056).
1314

1415
## [v0.4.4] - 2020-04-21
1516

snooty/parser.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,6 @@ def dispatch_visit(self, node: docutils.nodes.Node) -> None:
330330

331331
if not node["ids"]:
332332
self.diagnostics.append(InvalidURL(util.get_line(node)))
333-
# Remove the malformed node so it doesn't cause problems down the road
334-
self.state.pop()
335333
raise docutils.nodes.SkipNode()
336334

337335
node_id = node["ids"][0]

snooty/test_parser.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ def test_callable_target() -> None:
11101110
)
11111111

11121112

1113-
def test_no_weird_targets() -> None:
1113+
def test_no_hyperlink_references() -> None:
11141114
path = ROOT_PATH.joinpath(Path("test.rst"))
11151115
project_config = ProjectConfig(ROOT_PATH, "", source="./")
11161116
parser = rstparser.Parser(project_config, JSONVisitor)
@@ -1132,6 +1132,16 @@ def test_no_weird_targets() -> None:
11321132
diagnostics[1], InvalidURL
11331133
)
11341134

1135+
check_ast_testing_string(
1136+
page.ast,
1137+
"""
1138+
<root>
1139+
<paragraph><reference refname="ios-universal-links"><text>universal link</text></reference></paragraph>
1140+
<paragraph><reference refname="ios-universal-links"><text>universal link</text></reference></paragraph>
1141+
</root>
1142+
""",
1143+
)
1144+
11351145

11361146
def test_dates() -> None:
11371147
path = ROOT_PATH.joinpath(Path("test.rst"))

0 commit comments

Comments
 (0)