diff --git a/app/helpers/protocols_io_helper.rb b/app/helpers/protocols_io_helper.rb index 45c36fe54..4040ce6fb 100644 --- a/app/helpers/protocols_io_helper.rb +++ b/app/helpers/protocols_io_helper.rb @@ -52,17 +52,24 @@ module ProtocolsIoHelper tables[table_counter.to_s] = {} tr_number = table[0].scan(tr_regex).count diff = 5 - tr_number # always tables have atleast 5 rows - table_fixed_string = tr_number > 4 ? table[0] : table[0] + empty_tr_gen(diff) + table_fixed_string = tr_number > 4 ? table[0] : table[0] + empty_tbl_gen(diff) tr_strings = table_fixed_string.scan(tr_regex) contents = {} contents['data'] = [] tr_strings.each_with_index do |tr, tr_counter| td_strings = tr[0].scan(td_regex) contents['data'][tr_counter] = [] + td_counter = td_strings.count + diff = 5 - td_counter td_strings.each do |td| td_stripped = ActionController::Base.helpers.strip_tags(td[0]) contents['data'][tr_counter].push(td_stripped) end + next if td_counter >= 5 + while diff > 0 + contents['data'][tr_counter].push(' ') + diff -= 1 + end end tables[table_counter.to_s]['contents'] = Base64.encode64( contents.to_s.sub('=>', ':') @@ -73,7 +80,7 @@ module ProtocolsIoHelper return tables, string_without_tables end - def empty_tr_gen(number) + def empty_tbl_gen(number) result = '' while number > 0 result += '' @@ -409,8 +416,6 @@ module ProtocolsIoHelper newj[i.to_s]['tables'], table_str = protocolsio_string_to_table_element( newj[i.to_s]['description'] ) - # Base64.decode64(newj[i.to_s]['tables'][0]['contents']) - # byebug newj[i.to_s]['description'] = table_str end # steps newj