Skip to content

Commit

Permalink
Tiny follow-up to #663
Browse files Browse the repository at this point in the history
  • Loading branch information
robin850 committed Jan 26, 2019
1 parent 3100f65 commit 94f6e27
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog

* Avoid mutating the options hash passed to a render object.

Refs #663.

*Max Schwenk*

* Fix a segfault rendering quotes using `StripDown` and the `:quote`
option.

Expand Down
12 changes: 11 additions & 1 deletion test/custom_render_test.rb
Expand Up @@ -23,7 +23,7 @@ def test_simple_overload
end

def test_renderer_options
parser = Redcarpet::Markdown.new(SimpleRender.new({ with_toc_data: true }.freeze), {})
parser = Redcarpet::Markdown.new(SimpleRender.new(with_toc_data: true))
output = parser.render("# A title")

assert_match "My little poney", output
Expand All @@ -36,6 +36,16 @@ def test_markdown_options
assert_match "no_intra_emphasis", output
end

def test_original_options_hash_is_not_mutated
options = { with_toc_data: true }
render = SimpleRender.new(options)
parser = Redcarpet::Markdown.new(render, tables: true)

computed_options = render.instance_variable_get(:"@options")

refute_equal computed_options.object_id, options.object_id
end

class NilPreprocessRenderer < Redcarpet::Render::HTML
def preprocess(fulldoc)
nil
Expand Down

0 comments on commit 94f6e27

Please sign in to comment.