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

Commit 5646710

Browse files
committed
minor bug fixes
1 parent 6e3506b commit 5646710

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

runestone/activecode/activecode.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
from docutils.parsers.rst import directives
2121
from docutils.parsers.rst import Directive
2222
from .textfield import *
23-
import cgi
23+
24+
try:
25+
from html import escape # py3
26+
except ImportError:
27+
from cgi import escape # py2
2428

2529
def setup(app):
2630
app.add_directive('activecode', ActiveCode)
@@ -206,7 +210,7 @@ def run(self):
206210

207211
if self.options['language'] == 'html':
208212
self.options['language'] = 'htmlmixed'
209-
self.options['initialcode'] = cgi.escape(self.options['initialcode'])
213+
self.options['initialcode'] = escape(self.options['initialcode'])
210214

211215
if 'nocodelens' in self.options or self.options['language'] != 'python':
212216
self.options['codelens'] = ''

runestone/activecode/js/activecode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ HTMLActiveCode.prototype.runProg = function () {
513513

514514
HTMLActiveCode.prototype.init = function(opts) {
515515
ActiveCode.prototype.init.apply(this,arguments)
516-
this.code = $('<textarea />').html(orig.innerHTML).text();
516+
this.code = $('<textarea />').html(this.origElem.innerHTML).text();
517517
this.editor.setValue(this.code);
518518
};
519519

0 commit comments

Comments
 (0)