Skip to content

Commit

Permalink
Merge pull request #324 from ppworks/keep-header_ids-nil
Browse files Browse the repository at this point in the history
Fixed the issue where nil for header_ids
  • Loading branch information
gjtorikian authored Nov 27, 2024
2 parents c0be788 + b65c45c commit 3abd9b7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 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
2 changes: 1 addition & 1 deletion lib/commonmarker/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Commonmarker
VERSION = "2.0.0"
VERSION = "2.0.1"
end
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 3abd9b7

Please sign in to comment.