From cd91db4e71eb7015acc24cbc32e8d104bfa9f46a Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Fri, 17 Dec 2021 21:51:15 -0600 Subject: [PATCH] Change code style --- judge/highlight_code.py | 5 +++-- judge/views/submission.py | 2 +- resources/content-description.scss | 34 +++++++++++++++++++++++++++--- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/judge/highlight_code.py b/judge/highlight_code.py index ff330f7..308a58e 100644 --- a/judge/highlight_code.py +++ b/judge/highlight_code.py @@ -27,11 +27,12 @@ else: def wrap(self, source, outfile): return self._wrap_div(self._wrap_pre(_wrap_code(source))) - def highlight_code(code, language, cssclass='codehilite'): + def highlight_code(code, language, cssclass='codehilite', linenos=True): try: lexer = pygments.lexers.get_lexer_by_name(language) except pygments.util.ClassNotFound: return _make_pre_code(code) - # return mark_safe(pygments.highlight(code, lexer, HtmlCodeFormatter(cssclass=cssclass, linenos='table'))) + if linenos: + return mark_safe(pygments.highlight(code, lexer, HtmlCodeFormatter(cssclass=cssclass, linenos='table'))) return mark_safe(pygments.highlight(code, lexer, HtmlCodeFormatter(cssclass=cssclass))) diff --git a/judge/views/submission.py b/judge/views/submission.py index e4fcc2a..1c10872 100644 --- a/judge/views/submission.py +++ b/judge/views/submission.py @@ -111,7 +111,7 @@ class SubmissionSource(SubmissionDetailBase): submission = self.object context['raw_source'] = submission.source.source.rstrip('\n') context['highlighted_source'] = highlight_code( - submission.source.source, submission.language.pygments) + submission.source.source, submission.language.pygments, linenos=False) return context diff --git a/resources/content-description.scss b/resources/content-description.scss index 4c16058..13326d8 100644 --- a/resources/content-description.scss +++ b/resources/content-description.scss @@ -107,9 +107,9 @@ white-space: pre-wrap; word-wrap: break-word; margin: 1.5em 0 1.5em 0; - padding: 1em; - border: 1px solid $border_gray; - background-color: #f8f8f8; + padding: 0.5em; + padding-right: 0; + background-color: hsla(0,0%,92.5%,.5); color: black; border-radius: $widget_border_radius; } @@ -184,6 +184,34 @@ margin-right: auto; } +.codehilitetable { + .linenos { + width: 4%; + + pre { + color: rgba(0,0,0,.26); + background-color: rgba(0,0,0,.07); + width: 100%; + + span { + margin-left: 0.4em; + } + } + } + + .code { + padding-left: 0.2em; + + pre { + padding-left: 1em; + border-top-left-radius: 0; + border-bottom-left-radius: 0; + } + } + + width: 100%; +} + @media (min-width: 700px) { #common-content { display: flex;