File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed
Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 11require "cgi"
22require "json"
33require "securerandom"
4+ require "rouge"
45require "better_errors/error_page_style"
56
67module BetterErrors
@@ -158,7 +159,7 @@ def eval_and_respond(index, code)
158159 result , prompt , prefilled_input = @repls [ index ] . send_input ( code )
159160
160161 {
161- highlighted_input : CodeRay . scan ( code , :ruby ) . div ( wrap : nil ) ,
162+ highlighted_input : Rouge :: Formatters :: HTML . new . format ( Rouge :: Lexers :: Ruby . lex ( code ) ) ,
162163 prefilled_input : prefilled_input ,
163164 prompt : prompt ,
164165 result : result
Original file line number Diff line number Diff line change @@ -507,13 +507,20 @@ p.no-javascript-notice {
507507 padding :0 12px ;
508508}
509509
510- .code {
511- @import " syntax_highlighting " ;
510+ .code , .be-console .syntax-highlighted {
511+ text-shadow : none ;
512512
513+ @import " syntax_highlighting" ;
514+ }
515+ .code {
516+ // For now, the syntax-highlighted console only supports light mode.
517+ // Once the entire page has a dark theme, this should change.
513518 @media (prefers-color-scheme : dark ) {
514519 @import " syntax_highlighting_dark" ;
515520 }
521+ }
516522
523+ .code {
517524 margin-bottom : -1px ;
518525 border-top-left-radius :2px ;
519526 padding : 10px 0 ;
Original file line number Diff line number Diff line change 249249 self . writeOutput ( response . error + "\n" ) ;
250250 }
251251 self . writeOutput ( self . _prompt + " " ) ;
252- self . writeRawOutput ( response . highlighted_input + "\n" ) ;
252+ self . writeRawOutput ( "<span class='syntax-highlighted'>" + response . highlighted_input + "</span> \n" ) ;
253253 self . writeOutput ( response . result ) ;
254254 self . setPrompt ( response . prompt ) ;
255255 self . setInput ( response . prefilled_input ) ;
You can’t perform that action at this time.
0 commit comments