Sha256: 6ecb04c708a3bd7f33f4a9fc3f91818e164488f46fd4d54ec9fc0495031d2482
Contents?: true
Size: 1.84 KB
Versions: 2
Compression:
Stored size: 1.84 KB
Contents
# frozen_string_literal: true module Kitchen::Directions::BakeNumberedTable class V1 def bake(table:, number:, always_caption: false) table.wrap(%(<div class="os-table">)) table_label = "#{I18n.t(:table_label)} #{number}" table.document.pantry(name: :link_text).store table_label, label: table.id if table.top_titled? table.parent.add_class('os-top-titled-container') table.prepend(sibling: <<~HTML <div class="os-table-title">#{table.title}</div> HTML ) table.title_row.trash end table.parent.add_class('os-column-header-container') if table.column_header? # TODO: extra spaces added here to match legacy implementation, but probably not meaningful? new_summary = "#{table_label} " new_caption = '' caption_title = '' if (title = table.first("span[data-type='title']")&.cut) new_summary += title.text caption_title = <<~HTML \n<span class="os-title" data-type="title">#{title.children}</span> HTML end new_summary += ' ' if (caption = table.caption&.cut) new_summary += caption.text new_caption = <<~HTML \n<span class="os-caption">#{caption.children}</span> HTML elsif always_caption new_caption = <<~HTML \n<span class="os-caption"></span> HTML end table[:summary] = new_summary return if table.unnumbered? table.append(sibling: <<~HTML <div class="os-caption-container"> <span class="os-title-label">#{I18n.t(:table_label)} </span> <span class="os-number">#{number}</span> <span class="os-divider"> </span>#{caption_title} <span class="os-divider"> </span>#{new_caption} </div> HTML ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openstax_kitchen-3.2.0 | lib/kitchen/directions/bake_numbered_table/v1.rb |
openstax_kitchen-3.1.0 | lib/kitchen/directions/bake_numbered_table/v1.rb |