Skip to content

Commit

Permalink
feat(commonmarker): add commonmarker_exts to options
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhucheung committed May 6, 2019
1 parent 3e973e5 commit d3430c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/github/markup/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class Markdown < Implementation
MARKDOWN_GEMS = {
"commonmarker" => proc { |content, options: {}|
commonmarker_opts = [:GITHUB_PRE_LANG].concat(options.fetch(:commonmarker_opts, []))
CommonMarker.render_html(content, commonmarker_opts, [:tagfilter, :autolink, :table, :strikethrough])
commonmarker_exts = options.fetch(:commonmarker_exts, [:tagfilter, :autolink, :table, :strikethrough])
CommonMarker.render_html(content, commonmarker_opts, commonmarker_exts)
},
"github/markdown" => proc { |content, options: {}|
GitHub::Markdown.render(content)
Expand Down
3 changes: 3 additions & 0 deletions test/markup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,8 @@ def test_commonmarker_options

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]})

assert_equal "&lt;style>.red{color: #ff2727;}&lt;/style>\n", GitHub::Markup.render("test.md", "<style>.red{color: #ff2727;}</style>", options: {commonmarker_opts: [:UNSAFE]})
assert_equal "<style>.red{color: #ff2727;}</style>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "<style>.red{color: #ff2727;}</style>", options: {commonmarker_opts: [:UNSAFE], commonmarker_exts: [:autolink, :table, :strikethrough]})
end
end

0 comments on commit d3430c3

Please sign in to comment.