6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/cl_wiki/format/format.simpletable.rb', line 6
def FormatSimpleTable.format_content(content, page=nil)
table_attr = content.scan(/<simpletable(.*?)>/m).to_s.strip
table_attr = 'border="1"' if table_attr.empty?
content.gsub!(/<simpletable.*?>/m, '')
content.gsub!(/<\/simpletable>/m, '')
content.strip!
lines = content.split("\n")
lines.collect! do |ln|
ln.gsub!(/\t/, ' ')
'<tr><td>' + ln.gsub(/ +/, '</td><td>') + '</td></tr>'
end
lines.collect! do |ln| ln.gsub(/<td>\s*?<\/td>/, '<td> </td>') end
"<table #{table_attr}>\n" + lines.join("") + "</table>"
end
|