summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-02-21 19:21:28 -0500
committerRobert Speicher <rspeicher@gmail.com>2016-03-02 22:19:36 -0500
commit74751791a8bf27c5576832f73a57a5b110b423ad (patch)
tree77f820cdfec80249d95f84356750c8e94995d428 /lib
parent1fa7671f44291f78131c0fa31f6d1ffcb3ff6bbc (diff)
downloadgitlab-ce-74751791a8bf27c5576832f73a57a5b110b423ad.tar.gz
Add a PreProcessPipeline
Diffstat (limited to 'lib')
-rw-r--r--lib/banzai.rb4
-rw-r--r--lib/banzai/pipeline/pre_process_pipeline.rb16
-rw-r--r--lib/banzai/renderer.rb6
3 files changed, 26 insertions, 0 deletions
diff --git a/lib/banzai.rb b/lib/banzai.rb
index 093382261ae..b467413a7dd 100644
--- a/lib/banzai.rb
+++ b/lib/banzai.rb
@@ -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
diff --git a/lib/banzai/pipeline/pre_process_pipeline.rb b/lib/banzai/pipeline/pre_process_pipeline.rb
new file mode 100644
index 00000000000..c174f0b862d
--- /dev/null
+++ b/lib/banzai/pipeline/pre_process_pipeline.rb
@@ -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
diff --git a/lib/banzai/renderer.rb b/lib/banzai/renderer.rb
index 891c0fd7749..ae714c87dc5 100644
--- a/lib/banzai/renderer.rb
+++ b/lib/banzai/renderer.rb
@@ -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