From 3caf6c0fe5adc67b2b12ec64715239702662b098 Mon Sep 17 00:00:00 2001 From: Celeste Date: Sat, 13 Nov 2021 13:53:44 +0000 Subject: [PATCH] Add prre and post processor support. --- .gitignore | 1 + main.rb | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 80dcac1..6fe769f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/proc /themes /input /output diff --git a/main.rb b/main.rb index e5579ed..c7e83c4 100644 --- a/main.rb +++ b/main.rb @@ -53,6 +53,8 @@ for string in prelim end end +procfiles = Marshal.load(Marshal.dump(files)) + for file in directory file1 = "/" + file file1["input/"]= "" @@ -73,17 +75,44 @@ for file in structure end for file in files - handle = File.read(file) + if(File.exist?('input/inclusions.conf')) + list = IO.readlines("input/inclusions.conf", chomp: true) + for ext in list + if file.include? ext + handle = File.read(file) - output = file - output["input"]= "output" - IO.write(output, handle) + output = file + output["input"]= "output" + IO.write(output, handle) + end + end + else + handle = File.read(file) + + output = file + output["input"]= "output" + IO.write(output, handle) + end end def scope yield end +if(File.exist?('input/preproc.conf')) + list = IO.readlines("input/preproc.conf", chomp: true) + for proc in list + if(File.exist?('proc/' + proc +'/pre.sh')) + for file in procfiles + runner = `proc/#{proc}/pre.sh #{file}` + puts runner + end + else + puts proc +" does not support being used as a pre-processor." + end + end +end + for file in workspace text = File.read(file) template = File.read(theme_dir + "template.html") @@ -179,3 +208,17 @@ for file in workspace handle[".md"]= ".html" IO.write(handle, product) end + +if(File.exist?('input/postproc.conf')) + list = IO.readlines("input/postproc.conf", chomp: true) + for proc in list + if(File.exist?('proc/' + proc +'/post.sh')) + for file in procfiles + runner = `proc/#{proc}/post.sh #{file}` + puts runner + end + else + puts proc +" does not support being used as a post-processor." + end + end +end