mirror of
https://github.com/zekexiao/pocketlang.git
synced 2025-02-05 20:26:53 +08:00
try-online output changed to <pre> tag
This commit is contained in:
parent
bdd619c859
commit
d3bcbfb779
5
docs/static/codejar/linenumbers.js
vendored
5
docs/static/codejar/linenumbers.js
vendored
@ -8,7 +8,10 @@ function withLineNumbers(highlight, options = {}) {
|
||||
editor.addEventListener("scroll", () => lineNumbers.style.top = `-${editor.scrollTop}px`);
|
||||
}
|
||||
const code = editor.textContent || "";
|
||||
const linesCount = code.replace(/\n+$/, "\n").split("\n").length + 1;
|
||||
|
||||
//const linesCount = code.replace(/\n+$/, "\n").split("\n").length + 1;
|
||||
const linesCount = code.split("\n").length;
|
||||
|
||||
let text = "";
|
||||
for (let i = 1; i < linesCount; i++) {
|
||||
text += `${i}\n`;
|
||||
|
2
docs/static/css/try_online.css
vendored
2
docs/static/css/try_online.css
vendored
@ -130,7 +130,7 @@ body {
|
||||
padding: 16px 32px;
|
||||
}
|
||||
|
||||
#code-output.has-error {
|
||||
#code-output span.error-line {
|
||||
color: var(--color-output-error);
|
||||
}
|
||||
|
||||
|
6
docs/static/js/try_online.js
vendored
6
docs/static/js/try_online.js
vendored
@ -58,6 +58,12 @@ let code_example_titles = $$(".code-example-title");
|
||||
let code_highlight_fn = withLineNumbers(function(editor) {
|
||||
editor.textContent = editor.textContent;
|
||||
html = hljs.highlight(editor.textContent, {language : 'ruby'}).value;
|
||||
|
||||
// https://github.com/antonmedv/codejar/issues/22#issuecomment-773894139
|
||||
if (html.length > 2 && html.substring(html.length - 2, html.length) != '\n\n') {
|
||||
html += '\n'
|
||||
}
|
||||
|
||||
editor.innerHTML = html;
|
||||
});
|
||||
|
||||
|
@ -24,11 +24,11 @@ mergeInto(LibraryManager.library, {
|
||||
var out = document.getElementById("code-output");
|
||||
// To Indicate error (should be removed before each run request).
|
||||
out.classList.add("has-error");
|
||||
out.innerText += err_text + '\n';
|
||||
out.innerHTML += `<span class="error-line">${err_text}</span>\n`;
|
||||
},
|
||||
|
||||
js_writeFunction : function(message) {
|
||||
var out = document.getElementById("code-output");
|
||||
out.innerText += AsciiToString(message)
|
||||
out.innerText += AsciiToString(message);
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user