From 18d33b1fd608e95dce8c162ce74080d368d4cb51 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Tue, 2 Oct 2018 03:07:08 -0500 Subject: [PATCH] Cache converted markdown (#7159) Merge pull request 7159 --- lib/jekyll/converters/markdown.rb | 6 +++++- test/test_kramdown.rb | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 721bea64..284318cb 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -22,6 +22,8 @@ module Jekyll raise Errors::FatalException, "Bailing out; invalid Markdown processor." end + @cache = Jekyll::Cache.new("Jekyll::Converters::Markdown") + @setup = true end @@ -89,7 +91,9 @@ module Jekyll # Returns a String of the converted content. def convert(content) setup - @parser.convert(content) + @cache.getset(content) do + @parser.convert(content) + end end private diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index 94d6a4df..b55180b6 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -32,6 +32,7 @@ class TestKramdown < JekyllUnitTest @config = Jekyll.configuration(@config) @markdown = Converters::Markdown.new(@config) @markdown.setup + Jekyll::Cache.clear end should "fill symbolized keys into config for compatibility with kramdown" do @@ -94,7 +95,7 @@ class TestKramdown < JekyllUnitTest MARKDOWN div_highlight = ">div.highlight" selector = "div.highlighter-rouge#{div_highlight}>pre.highlight>code" - refute result.css(selector).empty? + refute(result.css(selector).empty?, result.to_html) end context "when a custom highlighter is chosen" do