Module: Asciidoctor::RFC::V2::Table

Included in:
Converter
Defined in:
lib/asciidoctor/rfc/v2/table.rb

Instance Method Summary collapse

Instance Method Details

#table(node) ⇒ Object

Syntax:

[[id]]
.Title
[suppress-title,align,style]
|===
|col | col
|===


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/asciidoctor/rfc/v2/table.rb', line 11

def table(node)
  has_body = false
  has_head = false
  style_value = case node.attr "grid"
                when "all"
                  "all"
                when "rows"
                  "headers"
                when "cols"
                  "full"
                when "none"
                  "none"
                else
                  "full"
                end
  warn "asciidoctor: WARNING (#{current_location(node)}): grid=rows attribute is not supported on tables" if node.attr("grid") == "rows"
  texttable_attributes = {
    anchor: node.id,
    title: node.title,
    'suppress-title': node.attr("supress-title") ? true : false,
    align: node.attr("align"),
    style: style_value,
  }

  noko do |xml|
    xml.texttable **attr_code(texttable_attributes) do |xml_texttable|
      [:head, :body, :foot].reject { |tblsec| node.rows[tblsec].empty? }.each do |tblsec|
        has_body = true if tblsec == :body
        has_head = true if tblsec == :head
      end
      warn "asciidoctor: WARNING (#{current_location(node)}): tables must have at least one body row" unless has_body
      warn "asciidoctor: WARNING (#{current_location(node)}): tables must have at least one head row" unless has_head

      # preamble, postamble elements not supported
      table_head node, xml_texttable
      table_body_and_foot node, xml_texttable
    end
  end
end