diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-02-22 03:22:02 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-03-05 02:05:48 +0300 |
commit | 8eaeda081615346e1d428e9f4f4402d3bb24b9f1 (patch) | |
tree | dbd6e45e2f3951c32760e6ad5d11076864d16e11 /spec/lib | |
parent | 74751791a8bf27c5576832f73a57a5b110b423ad (diff) |
Add YamlFrontMatterFilter to the PreProcessPipeline
This filter will detect YAML Front Matter and convert it to an HTML
table for prettier formatting.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/banzai/filter/yaml_front_matter_filter_spec.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/yaml_front_matter_filter_spec.rb b/spec/lib/banzai/filter/yaml_front_matter_filter_spec.rb new file mode 100644 index 00000000000..fe70eada7eb --- /dev/null +++ b/spec/lib/banzai/filter/yaml_front_matter_filter_spec.rb @@ -0,0 +1,53 @@ +require 'rails_helper' + +describe Banzai::Filter::YamlFrontMatterFilter, lib: true do + include FilterSpecHelper + + it 'allows for `encoding:` before the frontmatter' do + content = <<-MD.strip_heredoc + # encoding: UTF-8 + --- + foo: foo + --- + + # Header + + Content + MD + + output = filter(content) + + expect(output).not_to match 'encoding' + end + + it 'converts YAML frontmatter to a fenced code block' do + content = <<-MD.strip_heredoc + --- + bar: :bar_symbol + --- + + # Header + + Content + MD + + output = filter(content) + + aggregate_failures do + expect(output).not_to include '---' + expect(output).to include "```yaml\nbar: :bar_symbol\n```" + end + end + + context 'on content without frontmatter' do + it 'returns the content unmodified' do + content = <<-MD.strip_heredoc + # This is some Markdown + + It has no YAML frontmatter to parse. + MD + + expect(filter(content)).to eq content + end + end +end |