This commit is contained in:
Zanz2 2018-03-02 23:02:35 +01:00
parent 9c2a2956e3
commit 5bcda7f6de

View file

@ -52,7 +52,7 @@ module ProtocolsIoHelper
tables[table_counter.to_s] = {} tables[table_counter.to_s] = {}
tr_number = table[0].scan(tr_regex).count tr_number = table[0].scan(tr_regex).count
diff = 5 - tr_number # always tables have atleast 5 rows diff = 5 - tr_number # always tables have atleast 5 rows
table_fix_str = tr_number > 4 ? table[0] : table[0] + empty_tbl_gen(diff) table_fix_str = tr_number > 4 ? table[0] : table[0] + '<tr></tr>' * diff
tr_strings = table_fix_str.scan(tr_regex) tr_strings = table_fix_str.scan(tr_regex)
contents = {} contents = {}
contents['data'] = [] contents['data'] = []
@ -66,10 +66,7 @@ module ProtocolsIoHelper
contents['data'][tr_counter].push(td_stripped) contents['data'][tr_counter].push(td_stripped)
end end
next if td_counter >= 5 next if td_counter >= 5
while diff > 0 diff.times { contents['data'][tr_counter].push(' ') }
contents['data'][tr_counter].push(' ')
diff -= 1
end
end end
tables[table_counter.to_s]['contents'] = Base64.encode64( tables[table_counter.to_s]['contents'] = Base64.encode64(
contents.to_s.sub('=>', ':') contents.to_s.sub('=>', ':')
@ -79,15 +76,6 @@ module ProtocolsIoHelper
return tables, string_without_tables return tables, string_without_tables
end end
def empty_tbl_gen(number)
result = ''
while number > 0
result += '<tr></tr>'
number -= 1
end
result
end
def string_html_table_remove(description_string) def string_html_table_remove(description_string)
description_string.remove!("\n", "\t", "\r", "\f") description_string.remove!("\n", "\t", "\r", "\f")
table_whole_regex = %r{(<table\b[^>]*>.*?<\/table>)}m table_whole_regex = %r{(<table\b[^>]*>.*?<\/table>)}m