Skip to content

Instantly share code, notes, and snippets.

@loganhasson
Forked from adamflorin/redcarpet-crasher.rb
Last active August 29, 2015 14:07
Show Gist options
  • Save loganhasson/dcbc722e4121e7868756 to your computer and use it in GitHub Desktop.
Save loganhasson/dcbc722e4121e7868756 to your computer and use it in GitHub Desktop.
require 'redcarpet'
# Custom handler that raises error.
#
module Redcarpet
module Render
class Crasher < HTML
def paragraph(text)
raise "Error!"
end
end
end
end
redcarpet = Redcarpet::Markdown.new Redcarpet::Render::Crasher
# Will loop a certain number of times (always 17 for me for some reason)
# and then CRASH with:
#
# Assertion failed: (md->work_bufs[BUFFER_BLOCK].size == 0), function sd_markdown_render, file markdown.c, line 2544.
# Abort trap: 6
#
20.times do
begin
redcarpet.render "Body text."
rescue RuntimeError => e
puts "Error: #{e.message}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment