@@ -20,8 +20,8 @@ def initialize(key, values)
2020 @chapter = values [ "chapter" ]
2121 answer = decode_uri ( values [ "answer" ] )
2222 @answer = answer && !answer . empty? ? Regexp . new ( answer , 'mi' ) : nil
23- @ok = decode_uri ( values [ "ok" ] )
24- @error = decode_uri ( values [ "error" ] )
23+ @ok = decode_uri ( values [ "ok" ] ) . split ( '<br/>' )
24+ @error = decode_uri ( values [ "error" ] ) . split ( '<br/>' )
2525 @text = decode_uri ( values [ "text" ] )
2626 load_code = values [ "load_code" ]
2727 @load_code = load_code && !load_code . empty? ? decode_uri ( load_code ) : nil
@@ -57,12 +57,12 @@ def focus
5757 `#@native .focus()`
5858 end
5959
60- def mark_ok ( line_index )
61- `#@native .markText({line: line_index , ch: 0}, {line: line_index , ch: 99}, {className: "tryruby-output-green"})`
60+ def mark_ok ( line_from , line_to )
61+ `#@native .markText({line: line_from , ch: 0}, {line: line_to , ch: 99}, {className: "tryruby-output-green"})`
6262 end
6363
64- def mark_error ( line_index )
65- `#@native .markText({line: line_index , ch: 0}, {line: line_index , ch: 99}, {className: "tryruby-output-red"})`
64+ def mark_error ( line_from , line_to )
65+ `#@native .markText({line: line_from , ch: 0}, {line: line_to , ch: 99}, {className: "tryruby-output-red"})`
6666 end
6767end
6868
@@ -332,12 +332,19 @@ def eval_code(js_code)
332332
333333 # Check if output matches the defined answer regexp
334334 # and print status message
335+ print_to_output ( "\n " )
336+ from = count_lines
337+
335338 if !value_to_check . empty? && value_to_check . chomp . match ( @current_item . answer )
336- print_to_output ( "\n #{ @current_item . ok } " )
337- @output . mark_ok ( count_lines )
339+ @current_item . ok . each do |line |
340+ print_to_output ( line )
341+ end
342+ @output . mark_ok ( from , count_lines )
338343 else
339- print_to_output ( "\n #{ @current_item . error } " )
340- @output . mark_error ( count_lines )
344+ @current_item . error . each do |line |
345+ print_to_output ( line )
346+ end
347+ @output . mark_error ( from , count_lines )
341348 end
342349 end
343350
0 commit comments