diff --git a/features/hooks.feature b/features/hooks.feature
index f8c5f8fa..1deb7f98 100644
--- a/features/hooks.feature
+++ b/features/hooks.feature
@@ -362,6 +362,51 @@ Feature: Hooks
And I should see "
Page heading
" in "_site/memes/doc1.html"
And I should see "all your base
" in "_site/memes/doc1.html"
+ Scenario: Modify the converted HTML content of document of a particular collection before rendering layout
+ Given I have a _layouts directory
+ And I have a "_layouts/meme.html" file with content:
+ """
+ Page heading
+ {{ content }}
+ """
+ And I have a "_config.yml" file with content:
+ """
+ collections:
+ memes:
+ output: true
+ """
+ And I have a _memes directory
+ And I have a "_memes/doc1.md" file with content:
+ """
+ ---
+ layout: meme
+ text: all your base
+ ---
+ ### {{ page.text }}
+ """
+ And I have a _posts directory
+ And I have a "_posts/2016-01-01-example.md" file with content:
+ """
+ ---
+ layout: meme
+ text: all your base
+ ---
+ ### {{ page.text }}
+ """
+ And I have a _plugins directory
+ And I have a "_plugins/ext.rb" file with content:
+ """
+ Jekyll::Hooks.register :memes, :post_convert do |document|
+ document.content = document.content.gsub('h3', 'h4')
+ end
+ """
+ When I run jekyll build
+ Then I should get a zero exit status
+ And the _site directory should exist
+ And I should see "Page heading
" in "_site/memes/doc1.html"
+ And I should see "all your base
" in "_site/memes/doc1.html"
+ But I should see "all your base
" in "_site/2016/01/01/example.html"
+
Scenario: Update a document after rendering it, but before writing it to disk
Given I have a _plugins directory
And I have a "_plugins/ext.rb" file with content:
diff --git a/lib/jekyll/hooks.rb b/lib/jekyll/hooks.rb
index e3ddca8b..efb85269 100644
--- a/lib/jekyll/hooks.rb
+++ b/lib/jekyll/hooks.rb
@@ -70,10 +70,11 @@ module Jekyll
# register a single hook to be called later, internal API
def self.register_one(owner, event, priority, &block)
@registry[owner] ||= {
- :post_init => [],
- :pre_render => [],
- :post_render => [],
- :post_write => [],
+ :post_init => [],
+ :pre_render => [],
+ :post_convert => [],
+ :post_render => [],
+ :post_write => [],
}
unless @registry[owner][event]