Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion static/css/code/syntax-highlight.css
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,35 @@ CodeFlask mappings
--code-token-base
); /* Makes the text input cursor visible in dark mode */
}

.codeflask .codeflask__lines {
background: var(--code-background);
color: var(--code-token-punctuation);
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come a different font is being used here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to override what Codeflask sets; I've copied it from the parent element, I believe.

font-size: 13px;
line-height: 20px;
padding: var(--gap) 4px;
}
.codeflask.codeflask--has-line-numbers:before {
/* Codeflask inserts this inline, so it's necessary to override it. */
background: var(--code-background) !important;
}
.codeflask__lines__line {
position: relative;
}
.codeflask__lines__line.line_has_error {
color: var(--brand-error);
}
.codeflask__lines__line.line_has_error:before {
content: '';
display: block;
position: absolute;
left: 0;
top: 5px;
bottom: 5px;
width: 3px;
border-radius: 2px;
background: var(--brand-error);
}
.codeflask {
background: var(--code-background);
color: var(--code-token-base);
Expand Down
9 changes: 9 additions & 0 deletions static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function highlightOutput(target, childClassName) {

const editor = new CodeFlask("#editor-target", {
language: "gleam",
lineNumbers: true,
defaultTheme: false,
});
editor.addLanguage("gleam", prismGrammar);
Expand Down Expand Up @@ -134,6 +135,14 @@ worker.onmessage = (event) => {
appendCode(outputEl, result.log, "log");
}
if (result.error) {
const lines = [...result.error.matchAll(/\.gleam:(\d+)/gi)].map(
(x) => x[1],
);
for (const line of lines) {
document
.querySelector(`.codeflask__lines__line:nth-of-type(${line})`)
.classList.add("line_has_error");
}
appendCode(outputEl, result.error, "error");
}
if (result.js) {
Expand Down
Loading