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

  # 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.



32
33
34
# File 'lib/source2md/element.rb', line 32

def initialize(content)
  @content = content
end

Instance Method Details

#bodyObject



46
47
48
# File 'lib/source2md/element.rb', line 46

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

#headObject



42
43
44
# File 'lib/source2md/element.rb', line 42

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

#to_mdObject



36
37
38
39
40
# File 'lib/source2md/element.rb', line 36

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