Public: Methods for managing the a cell in an AsciiDoc table.
Public: An Integer of the number of columns this cell will span (default: nil)
Public: The internal Asciidoctor::Document for a cell that has the asciidoc style
Public: An Integer of the number of rows this cell will span (default: nil)
Public: Get/Set the Symbol style for this cell (default: nil)
# File lib/asciidoctor/table.rb, line 189 def initialize(column, text, attributes = {}, cursor = nil) super(column, :cell) @text = text @style = nil @colspan = nil @rowspan = nil # TODO feels hacky if !column.nil? @style = column.attributes['style'] update_attributes(column.attributes) end if !attributes.nil? @colspan = attributes.delete('colspan') @rowspan = attributes.delete('rowspan') # TODO eventualy remove the style attribute from the attributes hash #@style = attributes.delete('style') if attributes.has_key? 'style' @style = attributes['style'] if attributes.has_key? 'style' update_attributes(attributes) end # only allow AsciiDoc cells in non-header rows if @style == :asciidoc && !column.table.header_row? # FIXME hide doctitle from nested document; temporary workaround to fix # nested document seeing doctitle and assuming it has its own document title parent_doctitle = @document.attributes.delete('doctitle') # NOTE we need to process the first line of content as it may not have been processed # the included content cannot expect to match conditional terminators in the remaining # lines of table cell content, it must be self-contained logic inner_document_lines = @text.each_line.to_a unless inner_document_lines.empty? || !inner_document_lines.first.include?('::') unprocessed_lines = inner_document_lines[0..0] processed_lines = PreprocessorReader.new(@document, unprocessed_lines).readlines if processed_lines != unprocessed_lines inner_document_lines.shift inner_document_lines.unshift(*processed_lines) end end @inner_document = Document.new(inner_document_lines, :header_footer => false, :parent => @document, :cursor => cursor) @document.attributes['doctitle'] = parent_doctitle unless parent_doctitle.nil? end end
Public: Handles the body data (tbody, tfoot), applying styles and partitioning into paragraphs
# File lib/asciidoctor/table.rb, line 236 def content if @style == :asciidoc @inner_document.render else text.split(BLANK_LINE_PATTERN).map {|p| !@style || @style == :header ? p : Inline.new(parent, :quoted, p, :type => @style).render } end end
Public: Get the text with normal substitutions applied for this cell. Used for cells in the head rows
# File lib/asciidoctor/table.rb, line 231 def text apply_normal_subs(@text).strip end
# File lib/asciidoctor/table.rb, line 246 def to_s "#{super.to_s} - [text: #@text, colspan: #{@colspan || 1}, rowspan: #{@rowspan || 1}, attributes: #@attributes]" end