diff --git a/docs/_docs/configuration.md b/docs/_docs/configuration.md index cd0f2058..d5d6ebd7 100644 --- a/docs/_docs/configuration.md +++ b/docs/_docs/configuration.md @@ -688,6 +688,7 @@ kramdown: input: GFM hard_wrap: false footnote_nr: 1 + log_warnings: false ``` ## Liquid Options diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 087fdf78..3258ffab 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -80,6 +80,7 @@ module Jekyll "input" => "GFM", "hard_wrap" => false, "footnote_nr" => 1, + "log_warnings" => false, }, }.map { |k, v| [k, v.freeze] }].freeze diff --git a/lib/jekyll/converters/markdown/kramdown_parser.rb b/lib/jekyll/converters/markdown/kramdown_parser.rb index 9b6d55cc..b1015dcc 100644 --- a/lib/jekyll/converters/markdown/kramdown_parser.rb +++ b/lib/jekyll/converters/markdown/kramdown_parser.rb @@ -38,11 +38,12 @@ module Jekyll def convert(content) document = Kramdown::Document.new(content, @config) - html_output = document.to_html - document.warnings.each do |warning| - Jekyll.logger.warn "Kramdown warning:", warning + if @config["log_warnings"] + document.warnings.each do |warning| + Jekyll.logger.warn "Kramdown warning:", warning + end end - html_output + document.to_html end private diff --git a/lib/jekyll/converters/smartypants.rb b/lib/jekyll/converters/smartypants.rb index 16161e1d..4882c0e4 100644 --- a/lib/jekyll/converters/smartypants.rb +++ b/lib/jekyll/converters/smartypants.rb @@ -30,11 +30,12 @@ module Jekyll def convert(content) document = Kramdown::Document.new(content, @config) - html_output = document.to_html.chomp - document.warnings.each do |warning| - Jekyll.logger.warn "Kramdown warning:", warning + if @config["log_warnings"] + document.warnings.each do |warning| + Jekyll.logger.warn "Kramdown warning:", warning.sub(%r!^Warning:\s+!, "") + end end - html_output + document.to_html.chomp end end end diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index 80bcced3..d40a27e2 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -13,6 +13,7 @@ class TestKramdown < JekyllUnitTest "toc_levels" => "1..6", "auto_ids" => false, "footnote_nr" => 1, + "log_warnings" => true, "syntax_highlighter" => "rouge", "syntax_highlighter_opts" => {