Sha256: e392ea616bbf048ab664d855adeb91f931c3d4429b7da457326cacbf09eed075
Contents?: true
Size: 692 Bytes
Versions: 1
Compression:
Stored size: 692 Bytes
Contents
module Middleman module CoreExtensions class FrontMatter def parse_yaml_front_matter(content, full_path) yaml_regex = /\A(?:(```|~~~)\s?)? (---\s*\n.*?\n?)^((?:\1|---)\s*$\n?)/mx if content =~ yaml_regex content = content.sub(yaml_regex, '') begin data = YAML.load($2) || {} data = data.symbolize_keys rescue *YAML_ERRORS => e app.logger. error "YAML Exception parsing #{full_path}: #{e.message}" return false end else return false end [data, content] rescue [{}, content] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
middleman-markdown-yaml-front-matter-0.0.2 | lib/middleman/core_extensions/front_matter/markdown_style.rb |