-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/cargo/comrak-0.30.0
- Loading branch information
Showing
9 changed files
with
107 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class ConfigTest < Minitest::Test | ||
def test_process_options | ||
user_config = { | ||
parse: { | ||
smart: true, | ||
}, | ||
render: { | ||
unsafe: false, | ||
}, | ||
extension: { | ||
autolink: false, | ||
}, | ||
} | ||
processed_config = Commonmarker::Config.process_options(user_config) | ||
|
||
expected_config = [:parse, :render, :extension].each_with_object({}) do |type, hash| | ||
hash[type] = Commonmarker::Config::OPTIONS[type].merge(user_config[type] || {}) | ||
end | ||
|
||
assert_equal(expected_config, processed_config) | ||
end | ||
|
||
def test_process_plugins | ||
user_config = { | ||
syntax_highlighter: { | ||
path: "./themes", | ||
}, | ||
} | ||
processed_config = Commonmarker::Config.process_plugins(user_config) | ||
expected_config = [:syntax_highlighter].each_with_object({}) do |type, hash| | ||
hash[type] = Commonmarker::Config::PLUGINS[type].merge(user_config[type]) | ||
end | ||
|
||
assert_equal(expected_config, processed_config) | ||
end | ||
|
||
def test_config_merges_directly | ||
# hardbreaks work, the `\n` in between is rendered | ||
assert_equal("<p>aaaa<br />\nbbbb</p>\n", Commonmarker.to_html("aaaa\nbbbb")) | ||
|
||
# hardbreaks still work | ||
assert_equal("<p>aaaa<br />\nbbbb</p>\n", Commonmarker.to_html("aaaa\nbbbb", options: { render: { unsafe: false } })) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters