Commit d9a4ca59 authored by Yorick Peterse's avatar Yorick Peterse

Move pre_process into render_result

The method Banzai::Renderer.pre_process would always be called,
regardless of whether the Markdown to render was already cached or not.
In cache the document _was_ cached the output of the pre-processing
pipeline was ignored resulting in it doing nothing but wasting CPU
cycles.

This commit moves Banzai::Renderer.pre_process into
Banzai::Renderer.render_result so that it's _only_ used when needed.
parent 0468deaf
......@@ -14,6 +14,7 @@ v 8.9.0 (unreleased)
- Fix issue with arrow keys not working in search autocomplete dropdown
- Fix an issue where note polling stopped working if a window was in the
background during a refresh.
- Pre-processing Markdown now only happens when needed
- Make EmailsOnPushWorker use Sidekiq mailers queue
- Redesign all Devise emails. !4297
- Don't show 'Leave Project' to group members
......
......@@ -50,8 +50,6 @@ module GitlabMarkdownHelper
context[:project] ||= @project
text = Banzai.pre_process(text, context)
html = Banzai.render(text, context)
context.merge!(
......
......@@ -7,10 +7,6 @@ module Banzai
Renderer.render_result(text, context)
end
def self.pre_process(text, context)
Renderer.pre_process(text, context)
end
def self.post_process(html, context)
Renderer.post_process(html, context)
end
......
......@@ -30,13 +30,9 @@ module Banzai
end
def self.render_result(text, context = {})
Pipeline[context[:pipeline]].call(text, context)
end
text = Pipeline[:pre_process].to_html(text, context) if text
def self.pre_process(text, context)
pipeline = Pipeline[:pre_process]
pipeline.to_html(text, context)
Pipeline[context[:pipeline]].call(text, context)
end
# Perform post-processing on an HTML String
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment