6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/monty_ai/formatter.rb', line 6
def self.format(explanation, code = nil, filename = nil)
return explanation unless code
highlighter = SyntaxHighlighter.new
language = filename ? highlighter.detect_language(filename) : :text
highlighted_code = highlighter.highlight(code, language)
output = []
output << "```"
output << highlighted_code
output << "```"
output << ""
output << "Explanation:"
output << explanation
output.join("\n")
end
|