Module: Noteman::MDProcessor

Included in:
Note
Defined in:
lib/noteman/md_processor.rb

Defined Under Namespace

Classes: StackRenderer

Instance Method Summary collapse

Instance Method Details

#get_md(text) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/noteman/md_processor.rb', line 33

def get_md(text)
  sr = StackRenderer.new
  md = Redcarpet::Markdown.new(sr)

  md.render( text)
  sr.items
end

#get_metadata(text) ⇒ Object



24
25
26
27
# File 'lib/noteman/md_processor.rb', line 24

def (text)
  text =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
  meta = YAML.load($1) if $1
end

#remove_metadata(text) ⇒ Object



29
30
31
# File 'lib/noteman/md_processor.rb', line 29

def (text)
  text.sub /^(---\s*\n.*?\n?)^(---\s*$\n?)/m, ''
end