Class: Coradoc::AsciiDoc::Serializer::Serializers::TableCell

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/asciidoc/serializer/serializers/table_cell.rb

Instance Method Summary collapse

Methods inherited from Base

#serialize

Instance Method Details

#to_adoc(model, _options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/coradoc/asciidoc/serializer/serializers/table_cell.rb', line 8

def to_adoc(model, _options = {})
  @model = model
  _anchor = @model.gen_anchor(inline: true)

  # Handle content - if it's a single string, strip unicode; otherwise serialize children
  if @model.content.is_a?(String)
    _content = Coradoc.strip_unicode(@model.content) if defined?(Coradoc.strip_unicode)
    _content ||= @model.content
  elsif @model.content.is_a?(Array) && @model.content.size == 1 && @model.content.first.is_a?(String)
    _content = Coradoc.strip_unicode(@model.content.first) if defined?(Coradoc.strip_unicode)
    _content ||= @model.content.first.to_s
  else
    _content = serialize_children(@model.content)
  end

  # Build format specification: [colspan][.rowspan][halign][valign][style][*]
  format_spec = build_format_specification

  "#{format_spec}| #{_anchor}#{_content}"
end