1515#
1616__author__ = "tconzett"
1717
18+ from asyncore import write
1819from docutils import nodes
1920from docutils .parsers .rst import directives
21+ from runestone .common .xmlcommon import substitute_departure
2022from runestone .server .componentdb import addQuestionToDB , addHTMLToDB
2123from runestone .common .runestonedirective import RunestoneIdDirective , RunestoneIdNode
24+ from runestone .common .xmlcommon import substitute_departure , write_substitute
2225
2326
2427def setup (app ):
@@ -27,7 +30,8 @@ def setup(app):
2730 app .add_config_value (
2831 "showeval_div_class" , "runestone explainer alert alert-warning" , "html"
2932 )
30- app .add_node (ShowEvalNode , html = (visit_showeval_html , depart_showeval_html ))
33+ app .add_node (ShowEvalNode , html = (visit_showeval_html , depart_showeval_html ),
34+ xml = (visit_showeval_xml , substitute_departure ))
3135
3236
3337# Create visitors, so we can generate HTML after the doctree is resolve (where the question label is determined).
@@ -43,6 +47,11 @@ def visit_showeval_html(self, node):
4347 )
4448
4549
50+ def visit_showeval_xml (self , node ):
51+ html = CODE % node ["runestone_options" ]
52+ write_substitute (self , node , html )
53+
54+
4655def depart_showeval_html (self , node ):
4756 pass
4857
@@ -72,7 +81,8 @@ class ShowEval(RunestoneIdDirective):
7281 more code
7382 ~~~~
7483 more {{code}}{{what code becomes in step 1}}
75- more {{what code becomes in step 1}}{{what code becomes in step2}} ##Optional comment for step 2
84+ ##Optional comment for step 2
85+ more {{what code becomes in step 1}}{{what code becomes in step2}}
7686 as many steps as you want {{the first double braces}}{{animate into the second}} wherever.
7787
7888
@@ -108,7 +118,8 @@ def run(self):
108118 ~~~~
109119
110120 ''.join({{eggs}}{{['dogs', 'cats', 'moose']}}).upper().join(eggs)
111- {{''.join(['dogs', 'cats', 'moose'])}}{{'dogscatsmoose'}}.upper().join(eggs) ##I want to put a comment here!
121+ ##I want to put a comment here!
122+ {{''.join(['dogs', 'cats', 'moose'])}}{{'dogscatsmoose'}}.upper().join(eggs)
112123 {{'dogscatsmoose'.upper()}}{{'DOGSCATSMOOSE'}}.join(eggs)
113124 'DOGSCATSMOOSE'.join({{eggs}}{{['dogs', 'cats', 'moose']}})
114125 {{'DOGSCATSMOOSE'.join(['dogs', 'cats', 'moose'])}}{{'dogsDOGSCATSMOOSEcatsDOGSCATSMOOSEmoose'}}
0 commit comments