From 94d9272704ed44ebd2b39287c78b21510b12b217 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 5 Oct 2022 07:47:56 +0800 Subject: [PATCH] feat(web): add java support --- web/app/libs/uoj-html-lib.php | 13 +++++++---- web/app/libs/uoj-judger-lib.php | 2 +- web/app/views/page-header.php | 4 ++-- web/js/highlightjs.min.js | 39 ++++++++++++++++++++++++++++++++- web/js/uoj.js | 4 ++++ 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/web/app/libs/uoj-html-lib.php b/web/app/libs/uoj-html-lib.php index f470bd8..bb1fb7e 100644 --- a/web/app/libs/uoj-html-lib.php +++ b/web/app/libs/uoj-html-lib.php @@ -515,18 +515,23 @@ function echoSubmissionContent($submission, $requirement) { case 'C++20': case 'C++98': case 'C++03': - $sh_class = 'sh_cpp'; + $sh_class = 'sh_cpp language-cpp'; break; case 'Python2': case 'Python2.7': case 'Python3': - $sh_class = 'sh_python'; + $sh_class = 'sh_python language-python'; + break; + case 'Java8': + case 'Java11': + case 'Java17': + $sh_class = 'sh_java language-java'; break; case 'C': - $sh_class = 'sh_c'; + $sh_class = 'sh_c language-c'; break; case 'Pascal': - $sh_class = 'sh_pascal'; + $sh_class = 'sh_pascal language-pascal'; break; default: $sh_class = ''; diff --git a/web/app/libs/uoj-judger-lib.php b/web/app/libs/uoj-judger-lib.php index 1a57d37..dc416a3 100644 --- a/web/app/libs/uoj-judger-lib.php +++ b/web/app/libs/uoj-judger-lib.php @@ -1,6 +1,6 @@ - - + + diff --git a/web/js/highlightjs.min.js b/web/js/highlightjs.min.js index 6cc213a..181af5d 100644 --- a/web/js/highlightjs.min.js +++ b/web/js/highlightjs.min.js @@ -444,4 +444,41 @@ aliases:["dpr","dfm","pas","pascal"],case_insensitive:!0,keywords:r, illegal:/"|\$[G-Zg-z]|\/\*|<\/|\|/,contains:[n,i,e.NUMBER_MODE,{ className:"number",relevance:0,variants:[{begin:"\\$[0-9A-Fa-f]+"},{ begin:"&[0-7]+"},{begin:"%[01]+"}]},s,c,t].concat(a)}}})() -;hljs.registerLanguage("delphi",e)})(); \ No newline at end of file +;hljs.registerLanguage("delphi",e)})();/*! `java` grammar compiled for Highlight.js 11.6.0 */ +(()=>{var e=(()=>{"use strict" +;var e="\\.([0-9](_*[0-9])*)",a="[0-9a-fA-F](_*[0-9a-fA-F])*",n={ +className:"number",variants:[{ +begin:`(\\b([0-9](_*[0-9])*)((${e})|\\.)?|(${e}))[eE][+-]?([0-9](_*[0-9])*)[fFdD]?\\b` +},{begin:`\\b([0-9](_*[0-9])*)((${e})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{ +begin:`(${e})[fFdD]?\\b`},{begin:"\\b([0-9](_*[0-9])*)[fFdD]\\b"},{ +begin:`\\b0[xX]((${a})\\.?|(${a})?\\.(${a}))[pP][+-]?([0-9](_*[0-9])*)[fFdD]?\\b` +},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${a})[lL]?\\b`},{ +begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}], +relevance:0};function s(e,a,n){return-1===n?"":e.replace(a,(t=>s(e,a,n-1)))} +return e=>{ +const a=e.regex,t="[\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*",i=t+s("(?:<"+t+"~~~(?:\\s*,\\s*"+t+"~~~)*>)?",/~~~/g,2),r={ +keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed"], +literal:["false","true","null"], +type:["char","boolean","long","float","int","byte","short","double"], +built_in:["super","this"]},l={className:"meta",begin:"@"+t,contains:[{ +begin:/\(/,end:/\)/,contains:["self"]}]},c={className:"params",begin:/\(/, +end:/\)/,keywords:r,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0} +;return{name:"Java",aliases:["jsp"],keywords:r,illegal:/<\/|#/, +contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/, +relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{ +begin:/import java\.[a-z]+\./,keywords:"import",relevance:2 +},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/, +className:"string",contains:[e.BACKSLASH_ESCAPE] +},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{ +match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,t],className:{ +1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{ +begin:[a.concat(/(?!else)/,t),/\s+/,t,/\s+/,/=(?!=)/],className:{1:"type", +3:"variable",5:"operator"}},{begin:[/record/,/\s+/,t],className:{1:"keyword", +3:"title.class"},contains:[c,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{ +beginKeywords:"new throw return else",relevance:0},{ +begin:["(?:"+i+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{ +2:"title.function"},keywords:r,contains:[{className:"params",begin:/\(/, +end:/\)/,keywords:r,relevance:0, +contains:[l,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,n,e.C_BLOCK_COMMENT_MODE] +},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},n,l]}}})() +;hljs.registerLanguage("java",e)})(); diff --git a/web/js/uoj.js b/web/js/uoj.js index 71bced1..c44967b 100644 --- a/web/js/uoj.js +++ b/web/js/uoj.js @@ -618,6 +618,10 @@ function get_codemirror_mode(lang) { return 'text/x-python'; case 'Pascal': return 'text/x-pascal'; + case 'Java8': + case 'Java11': + case 'Java17': + return 'text/x-java'; case 'text': return 'text/plain'; default: