From 90bc37071355b52ceb0cfdf9bea3e131caf3901c Mon Sep 17 00:00:00 2001 From: Kester Date: Mon, 22 Apr 2024 16:49:19 -0400 Subject: [PATCH 01/14] Highlighting multi-line comments --- app/views/submissions/view.html.erb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/views/submissions/view.html.erb b/app/views/submissions/view.html.erb index eab17fa35..976bdf499 100755 --- a/app/views/submissions/view.html.erb +++ b/app/views/submissions/view.html.erb @@ -52,6 +52,23 @@ var headerPositionStr = null; <% end %> hljs.initHighlightingOnLoad(); + document.addEventListener('DOMContentLoaded', (event) => { + let combinedCode = ''; + document.querySelectorAll('pre code').forEach((block) => { + combinedCode += block.textContent + '\n'; + }); + + let highlightedCode = hljs.highlightAuto(combinedCode).value; + let commentSpans = highlightedCode.match(/([^<]*)<\/span>/g); + let commentContents = commentSpans.map(span => span.replace(/<[^>]+>/g, '')); + let splitContent = commentContents.flatMap(str => str.split('\n')); + + document.querySelectorAll('pre code').forEach((block, index) => { + if (block.textContent !== null && block.textContent !== "" && splitContent.includes(block.textContent.replace(/\n/g, ''))) { + block.innerHTML = `${block.textContent}`; + } + }); + }); PDFJS.workerSrc = "<%= asset_url 'pdf.worker.js' %>"; <%= render partial: "golden-layout" %> From a5461f25b945a5c455c68bace16a1458a860aea2 Mon Sep 17 00:00:00 2001 From: Kester Date: Mon, 22 Apr 2024 17:11:10 -0400 Subject: [PATCH 02/14] Stray multi line comments --- app/views/submissions/view.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/submissions/view.html.erb b/app/views/submissions/view.html.erb index 976bdf499..201e044c9 100755 --- a/app/views/submissions/view.html.erb +++ b/app/views/submissions/view.html.erb @@ -60,7 +60,7 @@ let highlightedCode = hljs.highlightAuto(combinedCode).value; let commentSpans = highlightedCode.match(/([^<]*)<\/span>/g); - let commentContents = commentSpans.map(span => span.replace(/<[^>]+>/g, '')); + let commentContents = commentSpans.map(span => span.replace(/<[^>]+>/g, '').replace(//g, '>')); let splitContent = commentContents.flatMap(str => str.split('\n')); document.querySelectorAll('pre code').forEach((block, index) => { From 35d99dbd40fd390a60796ebbe39b7381a72f3b85 Mon Sep 17 00:00:00 2001 From: Kester Date: Mon, 22 Apr 2024 17:18:48 -0400 Subject: [PATCH 03/14] Script stray comments fix --- app/views/submissions/view.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/submissions/view.html.erb b/app/views/submissions/view.html.erb index 201e044c9..cac29936e 100755 --- a/app/views/submissions/view.html.erb +++ b/app/views/submissions/view.html.erb @@ -60,7 +60,7 @@ let highlightedCode = hljs.highlightAuto(combinedCode).value; let commentSpans = highlightedCode.match(/([^<]*)<\/span>/g); - let commentContents = commentSpans.map(span => span.replace(/<[^>]+>/g, '').replace(//g, '>')); + let commentContents = commentSpans.map(span => span.replace(/<[^>]+>/g, '').replace(//g, '>').replace(/
-
+
From 0ced379fbf469abbb7e92b25e990a282505fa369 Mon Sep 17 00:00:00 2001 From: Kester Date: Fri, 26 Apr 2024 21:12:14 -0400 Subject: [PATCH 08/14] added comments and fixed indentation --- app/assets/stylesheets/_variables.scss | 1 + app/assets/stylesheets/annotations.scss | 2 +- app/views/submissions/view.html.erb | 136 ++++++++++++------------ 3 files changed, 72 insertions(+), 67 deletions(-) diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss index 70c691ebb..7cea9205f 100644 --- a/app/assets/stylesheets/_variables.scss +++ b/app/assets/stylesheets/_variables.scss @@ -14,3 +14,4 @@ $autolab-white: #fff; $autolab-selected-gray: #f5f5f5; $autolab-border-gray: #f4f1f1; $autolab-gray-text: #676464; +$autolab-highlight-comments: #008000; \ No newline at end of file diff --git a/app/assets/stylesheets/annotations.scss b/app/assets/stylesheets/annotations.scss index bd811a2cf..8cd47478c 100755 --- a/app/assets/stylesheets/annotations.scss +++ b/app/assets/stylesheets/annotations.scss @@ -940,7 +940,7 @@ span > .material-icons { } .hljs-comment span { - color: #008000 !important; + color: var($autolab-highlight-comments) !important; } .code-line div { diff --git a/app/views/submissions/view.html.erb b/app/views/submissions/view.html.erb index a2fb1e44d..28143ba5e 100755 --- a/app/views/submissions/view.html.erb +++ b/app/views/submissions/view.html.erb @@ -23,71 +23,75 @@
<%= render(partial: 'grades') %>
<%= render(partial: 'annotation_pane') %>
<%= render partial: "golden-layout" %> <% end %> @@ -139,4 +143,4 @@
-
+
\ No newline at end of file From aa313e48191ce4dcfebeb937a318db931d4b2c0e Mon Sep 17 00:00:00 2001 From: Kester Date: Fri, 26 Apr 2024 21:15:55 -0400 Subject: [PATCH 09/14] newline --- app/views/submissions/view.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/submissions/view.html.erb b/app/views/submissions/view.html.erb index 28143ba5e..13c5af28c 100755 --- a/app/views/submissions/view.html.erb +++ b/app/views/submissions/view.html.erb @@ -143,4 +143,4 @@
-
\ No newline at end of file +
From 507e904e1c16da3e2c2ad624100ceb21d2998a14 Mon Sep 17 00:00:00 2001 From: Kester Date: Fri, 26 Apr 2024 21:20:54 -0400 Subject: [PATCH 10/14] fixes indentation --- app/views/submissions/view.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/submissions/view.html.erb b/app/views/submissions/view.html.erb index 13c5af28c..367996bcd 100755 --- a/app/views/submissions/view.html.erb +++ b/app/views/submissions/view.html.erb @@ -24,9 +24,9 @@
<%= render(partial: 'annotation_pane') %>