module Lookbook::CodeFormatter

def beautify(source, language = "html")

def beautify(source, language = "html")
  source = source.strip
  result = language.downcase == "html" ? HtmlBeautifier.beautify(source) : source
  result.strip.html_safe
end

def highlight(source, language, opts = {})

def highlight(source, language, opts = {})
  source&.strip! unless opts[:strip] == false
  source&.gsub!("&gt;", ">")&.gsub!("&lt;", "<")
  language ||= "ruby"
  formatter = Formatter.new(opts)
  lexer = Rouge::Lexer.find(language.to_s) || Rouge::Lexer.find("plaintext")
  formatter.format(lexer.lex(source)).html_safe
end