Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add markup options #1249

Merged
merged 2 commits into from
Jan 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

  • _@
Suggested change
assert_equal "pod6", GitHub::Markup.renderer('README.pod6', '=begin pod').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