Add a PreProcessPipeline

This commit is contained in:
Robert Speicher 2016-02-21 19:21:28 -05:00
parent 1fa7671f44
commit 74751791a8
4 changed files with 28 additions and 0 deletions

View file

@ -50,6 +50,8 @@ module GitlabMarkdownHelper
context[:project] ||= @project
text = Banzai.pre_process(text, context)
html = Banzai.render(text, context)
context.merge!(

View file

@ -7,6 +7,10 @@ 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

View file

@ -0,0 +1,16 @@
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

View file

@ -31,6 +31,12 @@ module Banzai
Pipeline[context[:pipeline]].call(text, context)
end
def self.pre_process(text, context)
pipeline = Pipeline[:pre_process]
pipeline.to_html(text, context)
end
# Perform post-processing on an HTML String
#
# This method is used to perform state-dependent changes to a String of