Class: Markdownplus::PrettyJsonHandler

Inherits:
Handler
  • Object
show all
Defined in:
lib/markdownplus/handler.rb

Instance Method Summary collapse

Instance Method Details

#execute(input, parameters, variables, warnings, errors) ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'lib/markdownplus/handler.rb', line 53

def execute(input, parameters, variables, warnings, errors)
  begin
    obj = JSON.parse(input)
    output = JSON.pretty_generate(obj)
  rescue => e
    output = input
    errors << "Invalid json"
  end
  "```json\n#{output}\n```"
end