Class: Source2MD::Formatter::TypeTable

Inherits:
Base
  • Object
show all
Defined in:
lib/source2md/formatter/type_table.rb

Instance Attribute Summary

Attributes inherited from Base

#element

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Source2MD::Formatter::Base

Class Method Details

.accept?(element) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/source2md/formatter/type_table.rb', line 4

def self.accept?(element)
  !element.body.empty? && element.body.lines.all? { |e| e.match?(%r{#{RE.meta_re} \|.*\|$}) }
end

Instance Method Details

#to_mdObject



8
9
10
11
12
13
14
# File 'lib/source2md/formatter/type_table.rb', line 8

def to_md
  element.body
    .remove(%r{#{RE.meta_re} })
    .remove(/\A\|-.*?-\|\R/)  # top
    .remove(/^\|-.*?-\|\R\z/) # bottom
    .gsub(/-\+-/, "-|-")
end