9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/cl_wiki/format_simple_table.rb', line 9
def self.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!(%r{</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! { |ln| ln.gsub(%r{<td>\s*?</td>}, '<td> </td>') }
"<table #{table_attr}>\n#{lines.join('')}</table>"
end
|