Class: Source2MD::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/source2md/element.rb

Constant Summary collapse

PLUGINS =
[
  Formatter::TypeHidden,       # #+hidden: true
  Formatter::TypeEval,         # #+eval:
  Formatter::TypeCodeInclude,  # #+code_include: path/to/foo.html xml:SAMPLE.xml
  Formatter::TypeRawInclude,   # #+raw_include: path/to/file.txt
  Formatter::TypeParseInclude, # #+parse_include: path/to/file.txt
  Formatter::TypeTitle,        # #+title2: foo
  Formatter::TypeWarn,         # #+warn: foo
  Formatter::TypeAlert,        # #+alert: foo
  Formatter::TypeMethod,       # #+name: foo
  Formatter::TypeTable,        # # |-
  Formatter::TypeSourceBlock,  # #+BEGIN_SRC

  # Type that just removes the comment and does not wrap it
  Formatter::TypeMdHeader,     # # ---
  Formatter::TypeCodeBlock,    # # ```
  Formatter::TypeQuote,        # # > xxx
  Formatter::TypeList,         # # - xxx or 1. xxx
  Formatter::TypeUrlList,      # # http.*
  Formatter::TypeInlineImage,  # # ![]

  # Sentence (automatic wrap)
  Formatter::TypeText,         # # foo

  # Code block without wrapping
  Formatter::TypePartialCode,  # 1 + 2 # => 3

  # If not all match
  Formatter::TypeElse,
]

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Element

Returns a new instance of Element.



34
35
36
# File 'lib/source2md/element.rb', line 34

def initialize(content)
  @content = content
end

Instance Method Details

#bodyObject



48
49
50
# File 'lib/source2md/element.rb', line 48

def body
  @body ||= @content.remove(key_value_regexp).freeze
end

#headObject



44
45
46
# File 'lib/source2md/element.rb', line 44

def head
  @head ||= @content.scan(key_value_regexp).to_h.freeze
end

#to_mdObject



38
39
40
41
42
# File 'lib/source2md/element.rb', line 38

def to_md
  object = support_klass.new(self)
  debug_log(object)
  object.to_md
end