Class: MCMarkdown::Parsers::Frontmatter
- Inherits:
-
Object
- Object
- MCMarkdown::Parsers::Frontmatter
- Defined in:
- lib/mc_markdown/parsers/frontmatter.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize(content) ⇒ Frontmatter
constructor
A new instance of Frontmatter.
- #parsed ⇒ Object
Constructor Details
#initialize(content) ⇒ Frontmatter
Returns a new instance of Frontmatter.
7 8 9 |
# File 'lib/mc_markdown/parsers/frontmatter.rb', line 7 def initialize content @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/mc_markdown/parsers/frontmatter.rb', line 5 def content @content end |
Instance Method Details
#parsed ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mc_markdown/parsers/frontmatter.rb', line 11 def parsed match = content.match( frontmatter_regex ) raw_fm = match[1] content = match[2] if raw_fm && !raw_fm.empty? frontmatter = SafeYAML.load raw_fm, safe: true, deserialize_symbols: true, raise_on_unknown_tag: true else frontmatter = {} end [ frontmatter, content ] end |