aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-02-16 10:19:58 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-02-16 10:19:58 -0500
commitf0792e5fd977ca43480b898516abbf7300902c08 (patch)
tree254c3023c5716e220f21d29c6d9af8a10d9c94a0
parent01c3b68d4e207f91fecb8c75a0dd7d09fe7a2036 (diff)
Maintain •Show display even if there's an error
-rw-r--r--docs/repl.js19
-rw-r--r--docs/style.css1
2 files changed, 11 insertions, 9 deletions
diff --git a/docs/repl.js b/docs/repl.js
index 6e7a691a..ceea08c2 100644
--- a/docs/repl.js
+++ b/docs/repl.js
@@ -21,20 +21,23 @@ if (doc.count) {
let setExplain = e=>e;
let repl = () => {
let s=Array.from(doc.code.value), src=str(s);
- doc.rslt.classList.remove('err');
doc.rslt.textContent=' '; setExplain();
setcount(s);
setTimeout(() => {
+ doc.rslt.textContent = '';
+ let ssep='', sep = () => doc.rslt.append(ssep);
+ let disp = t => { sep(); ssep='\n'; doc.rslt.append(t); }
+ sysvals.show = (x,w) => { disp(fmt(x)); return x; }
+ didInitPlot = 0;
try {
- let out=[]; sysvals.show = (x,w) => { out.push(x); return x; }
- didInitPlot = 0;
let c=compile(src);
setExplain(src,c);
- out.push(run.apply(null,c));
- doc.rslt.textContent=out.map(fmt).join('\n');
+ disp(fmt(run.apply(null,c)));
} catch(e) {
- doc.rslt.classList.add('err');
- doc.rslt.textContent=fmtErr(e);
+ let n = document.createElement('span');
+ n.classList.add('Error');
+ n.innerText = fmtErr(e);
+ sep(); disp(n);
highlightErr(s, e);
}
sysvals.js=dojs; // In case it was disabled by fragment loading
@@ -107,7 +110,7 @@ let highlightErr = (s, e) => {
let l=0, sl = j=>s.slice(l,l=j).join('');
for (let i=0; i<n; i) {
h.append(sl(is[i++]));
- let m = document.createElement("mark");
+ let m = document.createElement('mark');
m.innerText = sl((pair?is[i++]:l)+1);
h.append(m);
}
diff --git a/docs/style.css b/docs/style.css
index 7f0dc388..8928fc26 100644
--- a/docs/style.css
+++ b/docs/style.css
@@ -123,7 +123,6 @@ pre, textarea, .highlight { padding: 0.8em; }
textarea { width: 100%; outline: none; resize: vertical; margin: 0; }
.cont { margin: 1.3em 0; position: relative; }
.rslt { background: none; border-top: none; margin: 0; overflow-x: initial; }
-.rslt.err { color: #d11; }
.kb {
line-height: 1.5;
width: 100%;