Class: Stic::Metadata::CommentYaml
- Defined in:
- lib/stic/metadata/comment_yaml.rb
Overview
The CommentYaml front matter parses YAML meta data from an line comment at the beginning of a page:
Constant Summary
Constants inherited from Yaml
Instance Method Summary collapse
Methods inherited from Yaml
#parse, #preprocess_content, #preprocess_data, #regexp
Methods inherited from Parser
Instance Method Details
#match(blob, str) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/stic/metadata/comment_yaml.rb', line 16 def match(blob, str) if (m = %r{\A(\s*(//|#)\s*)(.+:.+)}.match(str)) sep = m[1] case sep.strip when '#' return nil if %w(md markdown).include? blob.path.ext end scan_data str, sep end end |
#scan_data(str, sep) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/stic/metadata/comment_yaml.rb', line 28 def scan_data(str, sep) data, content = [], [] str.each_line do |line| if !line.starts_with?(sep) .. false content << line else data << line[sep.length..-1] end end {data: data.join("\n"), content: content.join("\n")} end |