Skip to content

Commit

Permalink
retain parent data when reseting title nodes in exercise and solution…
Browse files Browse the repository at this point in the history
… nodes
  • Loading branch information
mmcky committed Nov 24, 2021
1 parent 84a3d2a commit ebf67f5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sphinx_exercise/post_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

def resolve_enumerated_exercise_node_title(app, node):
title = node.children[0]
parent = title.parent
if isinstance(title, exercise_title):
node_number = get_node_number(app, node, "exercise")
updated_title = exercise_title()
Expand All @@ -31,6 +32,7 @@ def resolve_enumerated_exercise_node_title(app, node):
else:
updated_title += title.children[0]
updated_title += title.children[1:]
updated_title.parent = parent
node.children[0] = updated_title
node["title"] = title_text # TODO: Include subtitle text?
node.resolved_title = True
Expand All @@ -56,6 +58,7 @@ def resolve_solution_node_title(app, node):
""" Resolve Solution Nodes """
exercise_target = app.env.sphinx_exercise_registry[node.get("target_label")]["node"]
title = node.children[0]
parent = title.parent
if isinstance(title, solution_title):
new_title = solution_title()
new_title += build_reference_node(app, exercise_target)
Expand All @@ -74,6 +77,7 @@ def resolve_solution_node_title(app, node):
new_title += docutil_nodes.Text(")")
else:
new_title += title_element
new_title.parent = parent
node.children[0] = new_title
node.resolved_title = True
return node
Expand Down

0 comments on commit ebf67f5

Please sign in to comment.