Add prre and post processor support.

This commit is contained in:
abbie 2021-11-13 13:53:44 +00:00
parent 53a1afb8d7
commit 3caf6c0fe5
No known key found for this signature in database
GPG key ID: 04DDE463F9200F87
2 changed files with 48 additions and 4 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/proc
/themes /themes
/input /input
/output /output

43
main.rb
View file

@ -53,6 +53,8 @@ for string in prelim
end end
end end
procfiles = Marshal.load(Marshal.dump(files))
for file in directory for file in directory
file1 = "/" + file file1 = "/" + file
file1["input/"]= "" file1["input/"]= ""
@ -73,17 +75,44 @@ for file in structure
end end
for file in files for file in files
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) handle = File.read(file)
output = file output = file
output["input"]= "output" output["input"]= "output"
IO.write(output, handle) IO.write(output, handle)
end end
end
else
handle = File.read(file)
output = file
output["input"]= "output"
IO.write(output, handle)
end
end
def scope def scope
yield yield
end 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 for file in workspace
text = File.read(file) text = File.read(file)
template = File.read(theme_dir + "template.html") template = File.read(theme_dir + "template.html")
@ -179,3 +208,17 @@ for file in workspace
handle[".md"]= ".html" handle[".md"]= ".html"
IO.write(handle, product) IO.write(handle, product)
end 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