# coding: UTF-8
require 'test_helper'
class HTMLRenderTest < Test::Unit::TestCase
def setup
@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
@rndr = {
:no_html => Redcarpet::Render::HTML.new(:filter_html => true),
:no_images => Redcarpet::Render::HTML.new(:no_images => true),
:no_links => Redcarpet::Render::HTML.new(:no_links => true),
:safe_links => Redcarpet::Render::HTML.new(:safe_links_only => true),
:escape_html => Redcarpet::Render::HTML.new(:escape_html => true),
:hard_wrap => Redcarpet::Render::HTML.new(:hard_wrap => true),
}
end
def render_with(rndr, text)
Redcarpet::Markdown.new(rndr).render(text)
end
# Hint: overrides filter_html, no_images and no_links
def test_that_escape_html_works
source = <
<script>BAD</script>
<img src="/favicon.ico" />
EOE markdown = render_with(@rndr[:escape_html], source) html_equal expected, markdown end def test_that_filter_html_works markdown = render_with(@rndr[:no_html], 'Through NO ') html_equal "Through NO DOUBLE NO
\n", markdown end def test_filter_html_doesnt_break_two_space_hard_break markdown = render_with(@rndr[:no_html], "Lorem, \nipsum\n") html_equal "Lorem,
\nipsum