Class: Coradoc::AsciiDoc::Serializer::Serializers::Title

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

Instance Method Summary collapse

Methods inherited from Base

#serialize

Instance Method Details

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



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

def to_adoc(model, options_or_context = {})
  context = normalize_context(options_or_context)
  @model = model
  _anchor = model.anchor.nil? ? '' : "#{serialize_child(model.anchor, context)}\n"
  _content = serialize_children(model.content, context)

  # For ATX style headings, use # markers
  if model.style == 'atx'
    atx_markers = '#' * (model.level_int + 1)
    "#{_anchor}#{atx_markers} #{_content}#{model.line_break}"
  else
    # Default setext style
    "#{_anchor}#{style_str}#{level_str} #{_content}#{model.line_break}"
  end
end