forked from tslocke/hobo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
format_changelog
executable file
·61 lines (55 loc) · 2.17 KB
/
format_changelog
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/ruby
file=File.read(File.dirname(__FILE__)+"/../hobo/CHANGES.txt").to_a
out=[]; oline=''; voline=''; @oindent=0; @inlist=0
file.each_index do |line|
file[line].gsub!(/\</,"<")
file[line].gsub!(/\>/,">")
eof=(line+1)==file.length
blank=file[line].chomp.match(/^ *$/)
indent=blank ? @oindent : file[line].gsub(/^( *).*$/,'\1').chomp.length
nindent=eof ? 0 : file[line+1].gsub(/^( *).*$/,'\1').chomp.length
if (file[line] =~ /==.*==/)
version=file[line].gsub(/^ *===* *[^0-9]*(.*[^= ]) *===*.*$/,'\1').gsub(/\./,"_").chomp
file[line] = "<div class=class#{version}><h1>"+file[line]+"</h1>"
defined?(@oversion) && file[line] = "</div>"+file[line]
@oversion=version
elsif blank
if indent < nindent
file[line] = "<ul> <li>"+file[line]
elsif indent > nindent
if nindent > 0
file[line] = "</li><li>\n"+file[line]
else
file[line] = "</li>\n"+file[line]
end
file[line] = "</li> </ul>"+file[line]
else
file[line] = "</li><li>\n"
end
end
p "FOO #{eof} #{@oindent} #{indent} #{nindent} #{file[line]}"
@oindent=indent unless blank
#file[line] =~ /mmit/ && file[line] = "FOO"
end
f=File.open(File.dirname(__FILE__)+"/../hobo/CHANGES.html","w")
f.write '<html><head><style type="text/css">'+"\n"
f.write '.class0_7_5 {background-color: #fdc}'+"\n"
f.write '.class0_7_4 {background-color: #dff}'+"\n"
f.write '.class0_7_3 {background-color: #fdf}'+"\n"
f.write '.class0_7_2 {background-color: #ffd}'+"\n"
f.write '.class0_7_1 {background-color: #ddf}'+"\n"
f.write '.class0_7 {background-color: #ddd}'+"\n"
f.write '.class0_6_4 {background-color: #fdd}'+"\n"
f.write '.class0_6_3 {background-color: #dfd}'+"\n"
f.write '.class0_6_2 {background-color: #acc}'+"\n"
f.write '.class0_6_1 {background-color: #cac}'+"\n"
f.write '.class0_6 {background-color: #cca}'+"\n"
f.write '.class0_6-pre1 {background-color: #caa}'+"\n"
f.write '.class0_5_3 {background-color: #99c}'+"\n"
f.write '.class0_5_2 {background-color: #9c9}'+"\n"
f.write '.class0_5_1 {background-color: #c99}'+"\n"
f.write '.class0_5 {background-color: #88c}'+"\n"
f.write '</style></head><body>'+"\n"
f.write(file)
f.write '</body></html>'+"\n"
f.close