Skip to content

Commit

Permalink
Keep header_ids option as nil
Browse files Browse the repository at this point in the history
  • Loading branch information
ppworks committed Nov 27, 2024
1 parent c0be788 commit 916a5db
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/commonmarker/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class << self

def process_options(options)
{
parse: process_parse_options(options[:parse]),
render: process_render_options(options[:render]),
extension: process_extension_options(options[:extension]),
parse: process_parse_options(options[:parse].dup),
render: process_render_options(options[:render].dup),
extension: process_extension_options(options[:extension].dup),
}
end

Expand Down
35 changes: 35 additions & 0 deletions test/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,39 @@ def test_config_merges_directly
# hardbreaks still work
assert_equal("<p>aaaa<br />\nbbbb</p>\n", Commonmarker.to_html("aaaa\nbbbb", options: { render: { unsafe: false } }))
end

def test_same_config_again
user_config = {
extension: {
header_ids: nil,
},
}

text = "# Heading-1"
expected = "<h1>Heading-1</h1>\n"

assert_equal(expected, Commonmarker.to_html(text, options: user_config))

# expect same result
assert_equal(expected, Commonmarker.to_html(text, options: user_config))
end

def test_render_and_to_html_with_same_config
user_config = {
extension: {
header_ids: nil,
},
}

text = "# Heading-1"
expected = "<h1>Heading-1</h1>\n"

doc = Commonmarker.parse(text, options: user_config)
# doc.walk do |node|
# # do something
# end
doc.to_html(options: user_config)

assert_equal(expected, Commonmarker.to_html(text, options: user_config))
end
end

0 comments on commit 916a5db

Please sign in to comment.