Method: Brief::Util.split_doc_content

Defined in:
lib/brief/util.rb

.split_doc_content(raw_content) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/brief/util.rb', line 15

def self.split_doc_content(raw_content)
  if raw_content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
    content = raw_content[(Regexp.last_match[1].size + Regexp.last_match[2].size)..-1]
    frontmatter = YAML.load(Regexp.last_match[1]).to_mash
    [content, frontmatter]
  else
    [nil, {}.to_mash]
  end
end