From d3430c3f453546d9291a59c31539aa6233ebae2f Mon Sep 17 00:00:00 2001 From: jimcheung Date: Mon, 6 May 2019 18:08:59 +0800 Subject: [PATCH] feat(commonmarker): add commonmarker_exts to options --- lib/github/markup/markdown.rb | 3 ++- test/markup_test.rb | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/github/markup/markdown.rb b/lib/github/markup/markdown.rb index 11cf662d..7952bd3b 100644 --- a/lib/github/markup/markdown.rb +++ b/lib/github/markup/markdown.rb @@ -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) diff --git a/test/markup_test.rb b/test/markup_test.rb index 1ff2272a..da859944 100644 --- a/test/markup_test.rb +++ b/test/markup_test.rb @@ -120,5 +120,8 @@ def test_commonmarker_options assert_equal "

hello world

\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello world") assert_equal "

hello world

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