Skip to content

Commit

Permalink
Merge pull request #20 from angelasofiaremolinagutierrez/fix-exec-bug
Browse files Browse the repository at this point in the history
Fix string quotes bug
  • Loading branch information
AngelaRemolina authored Aug 15, 2021
2 parents f4ca325 + 9d39b6b commit 3ef8080
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
21 changes: 10 additions & 11 deletions runestone/activecode/js/activecode_brython.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ export default class BrythonActiveCode extends ActiveCode {
prog = `
<html>
<head>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].4/brython.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].4/brython_stdlib.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].5/brython.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].5/brython_stdlib.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/highlight.min.js"></script>
<style>
html, body{
height: max-content; width: 100%;
}
.container-pre{
background: white; font-size: 13px; line-height: 1.42857143; border: 1px solid #ccc; border-radius: 4px;
position: fixed; bottom: 0px; width: 94%; max-height: 200px; overflow: auto; clear: both; resize: both; transform: scale(1, -1);
background: white; font-size: 13px; line-height: 1.42857143; border: 1px solid #ccc; border-radius: 4px; visibility: hidden;
position: fixed; bottom: 0px; width: 94%; max-width: 96%; max-height: 200px; overflow: auto; clear: both; resize: both; transform: scale(1, -1);
}
pre {
position: sticky; padding: 12px; transform: scale(1, -1);
Expand All @@ -59,13 +59,13 @@ container <= preElem
class NewOut:
def write(self, data):
logger.innerHTML += str(data)
container.style.visibility = "visible"
sys.stderr = sys.stdout = NewOut()
def my_exec(code):
try:
exec(code, locals())
preElem.style.visibility = "visible"
out_header = document.createElement("text")
out_header.innerHTML = "Output"
out_header.style.font = "24px 'Arial'"
Expand Down Expand Up @@ -98,15 +98,14 @@ def my_exec(code):
error_header.innerHTML = "Error"
error_header.style.font = "24px 'Arial'"
preElem.prepend(error_header)
preElem.style.visibility = "visible"
preElem.style.backgroundColor = "#f2dede"
preElem.style.border = "1px solid #ebccd1"
logger.classList.add("python")
container.style.backgroundColor = "#f2dede"
container.style.border = "1px solid #ebccd1"
logger.classList.add("plaintext")
document <= container
my_exec("""${prog}
""")
my_prog = ${JSON.stringify(prog)}
my_exec(my_prog)
document <= html.SCRIPT("hljs.highlightAll();")
document <= html.SCRIPT("let container = document.querySelector('.container-pre'); let height = container.offsetHeight; document.body.style.paddingBottom = String(height)+'px';")
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 3ef8080

Please sign in to comment.