Commit 74751791 authored by Robert Speicher's avatar Robert Speicher

Add a PreProcessPipeline

parent 1fa7671f
...@@ -50,6 +50,8 @@ module GitlabMarkdownHelper ...@@ -50,6 +50,8 @@ module GitlabMarkdownHelper
context[:project] ||= @project context[:project] ||= @project
text = Banzai.pre_process(text, context)
html = Banzai.render(text, context) html = Banzai.render(text, context)
context.merge!( context.merge!(
......
...@@ -7,6 +7,10 @@ module Banzai ...@@ -7,6 +7,10 @@ module Banzai
Renderer.render_result(text, context) Renderer.render_result(text, context)
end end
def self.pre_process(text, context)
Renderer.pre_process(text, context)
end
def self.post_process(html, context) def self.post_process(html, context)
Renderer.post_process(html, context) Renderer.post_process(html, context)
end end
......
module Banzai
module Pipeline
class PreProcessPipeline < BasePipeline
def self.filters
[
]
end
def self.transform_context(context)
context.merge(
pre_process: true
)
end
end
end
end
...@@ -31,6 +31,12 @@ module Banzai ...@@ -31,6 +31,12 @@ module Banzai
Pipeline[context[:pipeline]].call(text, context) Pipeline[context[:pipeline]].call(text, context)
end end
def self.pre_process(text, context)
pipeline = Pipeline[:pre_process]
pipeline.to_html(text, context)
end
# Perform post-processing on an HTML String # Perform post-processing on an HTML String
# #
# This method is used to perform state-dependent changes to a String of # This method is used to perform state-dependent changes to a String of
......
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