Log kramdown warnings if log level is WARN (#6522)

Merge pull request 6522
This commit is contained in:
Florian Thomas 2017-11-09 14:11:05 +00:00 committed by jekyllbot
parent 1f3ce72f6b
commit fa22ebf056
3 changed files with 18 additions and 2 deletions

View File

@ -37,7 +37,12 @@ module Jekyll
end
def convert(content)
Kramdown::Document.new(content, @config).to_html
document = Kramdown::Document.new(content, @config)
html_output = document.to_html
document.warnings.each do |warning|
Jekyll.logger.warn "Kramdown warning:", warning
end
html_output
end
private

View File

@ -29,7 +29,12 @@ module Jekyll
end
def convert(content)
Kramdown::Document.new(content, @config).to_html.chomp
document = Kramdown::Document.new(content, @config)
html_output = document.to_html.chomp
document.warnings.each do |warning|
Jekyll.logger.warn "Kramdown warning:", warning
end
html_output
end
end
end

View File

@ -56,6 +56,12 @@ class TestKramdown < JekyllUnitTest
assert_equal "<h1>Some Header</h1>", @markdown.convert("# Some Header #").strip
end
should "should log kramdown warnings" do
allow_any_instance_of(Kramdown::Document).to receive(:warnings).and_return(["foo"])
expect(Jekyll.logger).to receive(:warn).with("Kramdown warning:", "foo")
@markdown.convert("Something")
end
context "when asked to convert smart quotes" do
should "convert" do
assert_match(