Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 21c9090

Browse files
committed
👌 Update node according to new pr
1 parent 45ecaa5 commit 21c9090

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

runestone/hparsons/hparsons.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
def setup(app):
3636
app.add_directive("hparsons", HParsonsDirective)
37-
app.add_node(HParsonsNode, html=(visit_hp_node, depart_hp_node))
37+
app.add_node(HParsonsNode, html=(visit_hp_html, depart_hp_html))
3838

3939

4040
TEMPLATE_START = """
@@ -60,35 +60,33 @@ def setup(app):
6060

6161

6262
class HParsonsNode(nodes.General, nodes.Element, RunestoneIdNode):
63-
def __init__(self, options, **kwargs):
64-
super(HParsonsNode, self).__init__(**kwargs)
65-
self.runestone_options = options
63+
pass
6664

6765

6866
# self for these functions is an instance of the writer class. For example
6967
# in html, self is sphinx.writers.html.SmartyPantsHTMLTranslator
7068
# The node that is passed as a parameter is an instance of our node class.
71-
def visit_hp_node(self, node):
69+
def visit_hp_html(self, node):
7270

73-
node.delimiter = "_start__{}_".format(node.runestone_options["divid"])
71+
node["delimiter"] = "_start__{}_".format(node["runestone_options"]["divid"])
7472

75-
self.body.append(node.delimiter)
73+
self.body.append(node["delimiter"])
7674

77-
res = TEMPLATE_START % node.runestone_options
75+
res = TEMPLATE_START % node["runestone_options"]
7876
self.body.append(res)
7977

8078

81-
def depart_hp_node(self, node):
82-
res = TEMPLATE_END % node.runestone_options
79+
def depart_hp_html(self, node):
80+
res = TEMPLATE_END % node["runestone_options"]
8381
self.body.append(res)
8482

8583
addHTMLToDB(
86-
node.runestone_options["divid"],
87-
node.runestone_options["basecourse"],
88-
"".join(self.body[self.body.index(node.delimiter) + 1 :]),
84+
node["runestone_options"]["divid"],
85+
node["runestone_options"]["basecourse"],
86+
"".join(self.body[self.body.index(node["delimiter"]) + 1 :]),
8987
)
9088

91-
self.body.remove(node.delimiter)
89+
self.body.remove(node["delimiter"])
9290

9391

9492
class HParsonsDirective(RunestoneIdDirective):
@@ -207,13 +205,14 @@ def run(self):
207205
"This should only affect the grading interface. Everything else should be fine."
208206
)
209207

210-
acnode = HParsonsNode(self.options, rawsource=self.block_text)
211-
acnode.source, acnode.line = self.state_machine.get_source_and_line(self.lineno)
212-
self.add_name(acnode) # make this divid available as a target for :ref:
208+
hpnode = HParsonsNode()
209+
hpnode["runestone_options"] = self.options
210+
hpnode["source"], hpnode["line"] = self.state_machine.get_source_and_line(self.lineno)
211+
self.add_name(hpnode) # make this divid available as a target for :ref:
213212

214213
maybeAddToAssignment(self)
215214
if explain_text:
216215
self.updateContent()
217-
self.state.nested_parse(explain_text, self.content_offset, acnode)
216+
self.state.nested_parse(explain_text, self.content_offset, hpnode)
218217

219-
return [acnode]
218+
return [hpnode]

0 commit comments

Comments
 (0)