Skip to content

Commit b717f31

Browse files
committed
Fix custom renderer with unsafe option missing pre lang
1 parent 3f232b3 commit b717f31

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/html/pipeline/markdown_filter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def call
3838

3939
render_options = [:GITHUB_PRE_LANG]
4040
render_options << :HARDBREAKS if context[:gfm] != false
41-
render_options = [:UNSAFE] if context[:unsafe]
41+
render_options << :UNSAFE if context[:unsafe]
4242

4343
doc = CommonMarker.render_doc(@text, parse_options, extensions)
4444
renderer.new(options: render_options, extensions: extensions).render(doc)

test/html/pipeline/markdown_filter_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ def test_legitimate_custom_renderer_without_tagfilter
119119

120120
assert_equal results, script
121121
end
122+
123+
def test_unsafe_custom_renderer_fenced_code_blocks_with_language
124+
doc = MarkdownFilter.to_document(@code.sub('```', '``` ruby'), unsafe: true, commonmarker_renderer: CustomRenderer)
125+
assert_equal 'ruby', doc.search('pre').first['lang']
126+
end
122127
end
123128

124129
class GFMTest < Minitest::Test

0 commit comments

Comments
 (0)