@@ -24,17 +24,17 @@ export default class BrythonActiveCode extends ActiveCode {
2424 prog = `
2525 <html>
2626 <head>
27- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.9.4 /brython.min.js"></script>
28- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.9.4 /brython_stdlib.min.js"></script>
27+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.9.5 /brython.min.js"></script>
28+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.9.5 /brython_stdlib.min.js"></script>
2929 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/styles/default.min.css">
3030 <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/highlight.min.js"></script>
3131 <style>
3232 html, body{
3333 height: max-content; width: 100%;
3434 }
3535 .container-pre{
36- background: white; font-size: 13px; line-height: 1.42857143; border: 1px solid #ccc; border-radius: 4px;
37- position: fixed; bottom: 0px; width: 94%; max-height: 200px; overflow: auto; clear: both; resize: both; transform: scale(1, -1);
36+ background: white; font-size: 13px; line-height: 1.42857143; border: 1px solid #ccc; border-radius: 4px; visibility: hidden;
37+ position: fixed; bottom: 0px; width: 94%; max-width: 96%; max- height: 200px; overflow: auto; clear: both; resize: both; transform: scale(1, -1);
3838 }
3939 pre {
4040 position: sticky; padding: 12px; transform: scale(1, -1);
@@ -59,13 +59,13 @@ container <= preElem
5959class NewOut:
6060 def write(self, data):
6161 logger.innerHTML += str(data)
62+ container.style.visibility = "visible"
6263
6364sys.stderr = sys.stdout = NewOut()
6465
6566def my_exec(code):
6667 try:
6768 exec(code, locals())
68- preElem.style.visibility = "visible"
6969 out_header = document.createElement("text")
7070 out_header.innerHTML = "Output"
7171 out_header.style.font = "24px 'Arial'"
@@ -98,15 +98,14 @@ def my_exec(code):
9898 error_header.innerHTML = "Error"
9999 error_header.style.font = "24px 'Arial'"
100100 preElem.prepend(error_header)
101- preElem.style.visibility = "visible"
102- preElem.style.backgroundColor = "#f2dede"
103- preElem.style.border = "1px solid #ebccd1"
104- logger.classList.add("python")
101+ container.style.backgroundColor = "#f2dede"
102+ container.style.border = "1px solid #ebccd1"
103+ logger.classList.add("plaintext")
105104
106105 document <= container
107106
108- my_exec(""" ${ prog }
109- """ )
107+ my_prog = ${ JSON . stringify ( prog ) }
108+ my_exec(my_prog )
110109
111110document <= html.SCRIPT("hljs.highlightAll();")
112111document <= html.SCRIPT("let container = document.querySelector('.container-pre'); let height = container.offsetHeight; document.body.style.paddingBottom = String(height)+'px';")
0 commit comments