-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
executable file
·42 lines (38 loc) · 1.25 KB
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env ruby
require 'rubygems'
require 'heredocparser'
#*******************************************************#
# #
# #
# Arunachalesha #
# $Id$ #
#*******************************************************#
if __FILE__ == $0
inputfilename=ARGV[0];
tmpl = ARGV[1];
tmpltext=File::read(tmpl);
myhash=parse_heredoc_to_hash(inputfilename);
["BODY","INTRO"].each { |key|
text = myhash[key];
if myhash.has_key?("CONVERT_BREAKS")
if myhash["CONVERT_BREAKS"] == "1"
text.gsub!("\n","<br />\n");
#text.gsub!("\n(\s+)") { |match| " " * match.size; }
end
end
# this enforces conversion to html but
# what if i do not want html conversion
if myhash.has_key?("FILTER") && myhash["FILTER"] == "maruku"
require 'maruku'
doc = Maruku.new(text)
text=doc.to_html
#text=%x{echo "#{text}" | /Users/rahul/bin/multis.sh}
end
myhash[key] = text;
}
tmpltext.gsub!( /##(.*?)##/ ) {
raise "Key '#{$1}' found in template but the value has not been set" unless ( myhash.has_key?( $1 ) )
myhash[ $1 ].to_s
}
print tmpltext, "\n";
end