Sha256: db4feb6b3d40c20c2bcb62cd9ffe3c82c8c0f7b1ba55d60e968b4099dda51575
Contents?: true
Size: 873 Bytes
Versions: 17
Compression:
Stored size: 873 Bytes
Contents
# frozen_string_literal: true class FormatSimpleTable < ClWiki::CustomFormatter def self.match_re %r{<simpletable.*?>.*?</simpletable>}m end 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>') } # if you do a .join("\n"), then the \n will be converted to <br> # ... so don't do that "<table #{table_attr}>\n#{lines.join('')}</table>" end end ClWiki::CustomFormatters.instance.register(FormatSimpleTable)
Version data entries
17 entries across 17 versions & 1 rubygems