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
  • Select an option

  • Save loganhasson/dcbc722e4121e7868756 to your computer and use it in GitHub Desktop.

Select an option

Save loganhasson/dcbc722e4121e7868756 to your computer and use it in GitHub Desktop.

Revisions

  1. @adamflorin adamflorin created this gist Oct 18, 2013.
    29 changes: 29 additions & 0 deletions redcarpet-crasher.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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