Add a PreProcessPipeline
This commit is contained in:
parent
1fa7671f44
commit
74751791a8
4 changed files with 28 additions and 0 deletions
|
@ -50,6 +50,8 @@ module GitlabMarkdownHelper
|
|||
|
||||
context[:project] ||= @project
|
||||
|
||||
text = Banzai.pre_process(text, context)
|
||||
|
||||
html = Banzai.render(text, context)
|
||||
|
||||
context.merge!(
|
||||
|
|
|
@ -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
|
||||
|
|
16
lib/banzai/pipeline/pre_process_pipeline.rb
Normal file
16
lib/banzai/pipeline/pre_process_pipeline.rb
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue