Skip to content

Commit

Permalink
Merge pull request #1249 from jinhucheung/perf-render-params
Browse files Browse the repository at this point in the history
add markup options
  • Loading branch information
Ashe Connor committed Jan 6, 2019
2 parents ea51182 + 32909da commit 8f436ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/github/markup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def render(filename, content, symlink: false, options: {})
end
end

def render_s(symbol, content)
def render_s(symbol, content, options: {})
raise ArgumentError, 'Can not render a nil.' if content.nil?

if markups.key?(symbol)
markups[symbol].render(nil, content)
markups[symbol].render(nil, content, options: options)
else
content
end
Expand Down
7 changes: 5 additions & 2 deletions test/markup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def call
message
end
end

def test_knows_what_it_can_and_cannot_render
assert_equal false, GitHub::Markup.can_render?('README.html', '<h1>Title</h1>')
assert_equal true, GitHub::Markup.can_render?('README.markdown', '=== Title')
Expand All @@ -92,7 +92,7 @@ def test_each_render_has_a_name
assert_equal "pod", GitHub::Markup.renderer('README.pod', '=head1').name
assert_equal "pod6", GitHub::Markup.renderer('README.pod6', '=begin pod').name
end

def test_rendering_by_symbol
assert_equal '<p><code>test</code></p>', GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, '`test`').strip
end
Expand All @@ -117,5 +117,8 @@ def test_preserve_markup
def test_commonmarker_options
assert_equal "<p>hello <!-- raw HTML omitted --> world</p>\n", GitHub::Markup.render("test.md", "hello <bad> world")
assert_equal "<p>hello <bad> world</p>\n", GitHub::Markup.render("test.md", "hello <bad> world", options: {commonmarker_opts: [:UNSAFE]})

assert_equal "<p>hello <!-- raw HTML omitted --> world</p>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello <bad> world")
assert_equal "<p>hello <bad> world</p>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello <bad> world", options: {commonmarker_opts: [:UNSAFE]})
end
end

0 comments on commit 8f436ff

Please sign in to comment.