benoit 0.2.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +1 -2
  3. data/.rspec +1 -1
  4. data/Assetfile +19 -4
  5. data/Gemfile.lock +29 -5
  6. data/Guardfile +28 -0
  7. data/Rakefile +2 -0
  8. data/benoit.gemspec +5 -0
  9. data/bin/benoit +25 -7
  10. data/lib/benoit/cadenza.rb +2 -0
  11. data/lib/benoit/cadenza/blocks.rb +18 -0
  12. data/lib/benoit/compiler_error.rb +5 -1
  13. data/lib/benoit/filters/base_filter.rb +4 -5
  14. data/lib/benoit/filters/cadenza_filter.rb +19 -16
  15. data/lib/benoit/filters/markdown_filter.rb +36 -4
  16. data/lib/benoit/logger.rb +2 -2
  17. data/lib/benoit/pipeline_project.rb +23 -23
  18. data/lib/benoit/server.rb +47 -0
  19. data/lib/benoit/server/remote.rb +29 -0
  20. data/lib/benoit/utils/finds_layouts_for_template.rb +28 -30
  21. data/lib/benoit/version.rb +1 -1
  22. data/spec/features/build_command.feature +1 -1
  23. data/spec/features/frontmatter_metadata.feature +3 -21
  24. data/spec/features/javascript_files.feature +1 -0
  25. data/spec/features/markdown_files.feature +41 -0
  26. data/spec/features/output_filters.feature +2 -7
  27. data/spec/features/page_layouts.feature +4 -28
  28. data/spec/features/pagination.feature +1 -0
  29. data/spec/lib/filters/base_filter_spec.rb +4 -33
  30. data/spec/lib/filters/markdown_filter_spec.rb +31 -8
  31. data/spec/lib/filters/sass_filter_spec.rb +2 -2
  32. data/spec/lib/site_context_spec.rb +2 -2
  33. data/spec/steps/staticly_steps.rb +1 -1
  34. data/spec/support/spec_helpers/memory_file_wrapper.rb +2 -6
  35. data/vendor/rake-pipeline/GETTING_STARTED.md +11 -11
  36. data/vendor/rake-pipeline/bin/rakep +1 -1
  37. data/vendor/rake-pipeline/lib/rake-pipeline.rb +2 -49
  38. data/vendor/rake-pipeline/lib/rake-pipeline/cli.rb +0 -1
  39. data/vendor/rake-pipeline/lib/rake-pipeline/file_wrapper.rb +2 -9
  40. data/vendor/rake-pipeline/lib/rake-pipeline/filter.rb +1 -19
  41. data/vendor/rake-pipeline/lib/rake-pipeline/manifest.rb +4 -0
  42. data/vendor/rake-pipeline/lib/rake-pipeline/middleware.rb +1 -2
  43. data/vendor/rake-pipeline/lib/rake-pipeline/project.rb +3 -2
  44. data/vendor/rake-pipeline/rake-pipeline.gemspec +1 -1
  45. data/vendor/rake-pipeline/spec/cli_spec.rb +0 -2
  46. data/vendor/rake-pipeline/spec/concat_filter_spec.rb +4 -4
  47. data/vendor/rake-pipeline/spec/filter_spec.rb +0 -35
  48. data/vendor/rake-pipeline/spec/gsub_filter_spec.rb +5 -5
  49. data/vendor/rake-pipeline/spec/ordering_concat_filter_spec.rb +4 -4
  50. data/vendor/rake-pipeline/spec/rake_acceptance_spec.rb +18 -0
  51. data/vendor/rake-pipeline/spec/support/spec_helpers/filters.rb +1 -1
  52. data/vendor/rake-pipeline/spec/support/spec_helpers/memory_file_wrapper.rb +2 -6
  53. metadata +77 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGI5ODI4OTYwYWE3MmExY2U1ODUwZWI3Nzg3MmUyMzE4NTk1ZjJjYg==
4
+ MjFlM2RiMGE0N2VlNzNjYzA3YTcwYmMxMzZiNGU3NjAzN2U2MzViYQ==
5
5
  data.tar.gz: !binary |-
6
- ZGM5NTEyY2M3NzRlMTQyZTNmM2E2NDk4ZjhlM2IzMDk5MmYxZmI4MQ==
6
+ YmZkZjFiNDZlMTgwY2UxZDdhZTVlNmJiMTA4Y2I4YmIyYTQxODM1YQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZjVkMDA0YTg0YzY5NWNmZmI4YWY3NzQzYWIxMmNlOWM1YWE4ZjRlYjRiZDQ4
10
- MzIwYTRiNmU5YTIwNGYwZTI2YjhlN2NmYjY4MDA3NjI1MjY2ZjhjY2JkZGI1
11
- OTU3M2VkYzE2ZTBmODZiMzI4ZTE0MDJlNmZkNjg4MTVkNDU2NzM=
9
+ ZWMyOGQwMTk4NGYwZjllNTMwZmY4M2RhNTJhYWRkMGQwMTRmYzY0NjE1YTcw
10
+ ZGM1MTg5ZDQzZDkyNzMzYTA3N2U1ZDUzMWRlZGRiYjBhNWE4OGMyZDFmMzdi
11
+ ZDFmNGU2ZjJkNzMyZTQ0MzE4NDVjMmNhNDU1NDhkYzYwNWNlZjc=
12
12
  data.tar.gz: !binary |-
13
- MTFhZjIzOTNlZjZlYWEyMGJjMWVlMjNhODNkM2JhNmM1ZTViODZkOWI3MDA5
14
- MjUxMTZjOGY5MGJjNDVkMjllN2U2NmIyOTI5NWRmZTE3MTk2YjZmZjVlMDk1
15
- NzI4ODVhMTZiMWZhM2FlMWExNTlhYWU0YjkyOGY2OTMwOWMyODA=
13
+ ODdjMjU4Njg0Y2E4MzFjNjczOTYxY2U2MDM4YTM3MDFmYjhhZTUwNjVlOTJl
14
+ NDgwYjY1ZThkZjBhMzI3NDRlZWMxNjFhZDQwOWM5MjE4MTA0ZmJlODZjNjg5
15
+ MjU4OWVhNTk1N2QxNzcyOTI5ZDAzOWU1NDExN2ZmYzA2MGNlYjY=
data/.gitignore CHANGED
@@ -1,4 +1,3 @@
1
1
  .bundle
2
- bundle/ruby/1.9.1/gems/compass-*/examples
3
- bundle/ruby/1.9.1/gems/compass-*/test
2
+ bundle
4
3
  tmp
data/.rspec CHANGED
@@ -1 +1 @@
1
- -I ./lib/benoit -I ./spec/support -I ./vendor/rake-pipeline/lib -fd
1
+ -I ./lib -I ./spec/support -I ./vendor/rake-pipeline/lib -fd
data/Assetfile CHANGED
@@ -1,6 +1,23 @@
1
1
  require 'benoit/pipeline/dsl_extensions'
2
2
 
3
- before_filter Benoit::Filters::MetadataCleaner
3
+ # before_filter Benoit::Filters::MetadataCleaner
4
+
5
+ class EverythingElse < Rake::Pipeline::Filter
6
+
7
+ processes_binary_files
8
+
9
+ PROCESSED = %w(js html css scss)
10
+
11
+ def generate_output(inputs, output)
12
+ inputs.each do |input|
13
+ unless PROCESSED.include?(File.extname(input.path))
14
+ output.write input.read
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ after_filter EverythingElse
4
21
 
5
22
  input Dir.pwd do
6
23
 
@@ -52,10 +69,8 @@ input Dir.pwd do
52
69
  filter Benoit::Filters::SassFilter, additional_load_paths: ["styles", "css"]
53
70
  end
54
71
 
55
- needs_pagination "*.html"
56
-
57
72
  match "**/*.html" do
58
- filter Benoit::Filters::ContentPageFilter
73
+ # filter Benoit::Filters::ContentPageFilter
59
74
  filter Benoit::Filters::CadenzaFilter
60
75
  end
61
76
 
@@ -1,18 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- benoit (0.2.2)
4
+ benoit (0.4.0)
5
5
  cadenza (~> 0.8.0)
6
6
  chunky_png (~> 1.2.0)
7
7
  compass (~> 0.13.alpha)
8
8
  gli (~> 2.5.3)
9
9
  inflecto (~> 0.0.2)
10
+ kramdown (~> 1.1.0)
10
11
  kronic (~> 1.1.3)
11
12
  multi_json (~> 1.5.0)
12
13
  rake-pipeline-web-filters (~> 0.7.0)
13
14
  redcarpet (~> 2.2.2)
14
15
  sass (~> 3.2.0)
15
16
  stamp (~> 0.5.0)
17
+ thin (~> 1.5.1)
16
18
 
17
19
  PATH
18
20
  remote: vendor/frontmatter
@@ -24,7 +26,7 @@ PATH
24
26
  specs:
25
27
  rake-pipeline (0.8.0)
26
28
  json
27
- rake (~> 0.9.0)
29
+ rake (~> 10.0.0)
28
30
  thor
29
31
 
30
32
  GEM
@@ -50,15 +52,29 @@ GEM
50
52
  diff-lcs (>= 1.1.3)
51
53
  gherkin (~> 2.11.7)
52
54
  multi_json (~> 1.3)
55
+ daemons (1.1.9)
53
56
  diff-lcs (1.2.4)
57
+ eventmachine (1.0.3)
54
58
  ffi (1.7.0)
59
+ formatador (0.2.4)
55
60
  gherkin (2.11.8)
56
61
  multi_json (~> 1.3)
57
62
  gli (2.5.6)
63
+ guard (1.7.0)
64
+ formatador (>= 0.2.4)
65
+ listen (>= 0.6.0)
66
+ lumberjack (>= 1.0.2)
67
+ pry (>= 0.9.10)
68
+ thor (>= 0.14.6)
69
+ guard-rspec (2.5.4)
70
+ guard (>= 1.1)
71
+ rspec (~> 2.11)
58
72
  inflecto (0.0.2)
59
- json (1.7.7)
73
+ json (1.8.0)
74
+ kramdown (1.1.0)
60
75
  kronic (1.1.3)
61
76
  listen (0.7.3)
77
+ lumberjack (1.0.4)
62
78
  method_source (0.8.1)
63
79
  multi_json (1.5.1)
64
80
  pry (0.9.12)
@@ -71,10 +87,11 @@ GEM
71
87
  pry (~> 0.9)
72
88
  slop (~> 3.0)
73
89
  rack (1.5.2)
74
- rake (0.9.6)
90
+ rake (10.0.4)
75
91
  rake-pipeline-web-filters (0.7.0)
76
92
  rack
77
93
  rake-pipeline (~> 0.6)
94
+ rb-fsevent (0.9.3)
78
95
  redcarpet (2.2.2)
79
96
  rspec (2.13.0)
80
97
  rspec-core (~> 2.13.0)
@@ -84,9 +101,13 @@ GEM
84
101
  rspec-expectations (2.13.0)
85
102
  diff-lcs (>= 1.1.3, < 2.0)
86
103
  rspec-mocks (2.13.1)
87
- sass (3.2.7)
104
+ sass (3.2.9)
88
105
  slop (3.4.4)
89
106
  stamp (0.5.0)
107
+ thin (1.5.1)
108
+ daemons (>= 1.0.9)
109
+ eventmachine (>= 0.12.6)
110
+ rack (>= 1.0.0)
90
111
  thor (0.18.1)
91
112
  turnip (1.1.0)
92
113
  gherkin (>= 2.5)
@@ -101,10 +122,13 @@ DEPENDENCIES
101
122
  aruba
102
123
  benoit!
103
124
  frontmatter!
125
+ guard
126
+ guard-rspec
104
127
  pry
105
128
  pry-nav
106
129
  pry-remote
107
130
  rake-pipeline!
131
+ rb-fsevent (~> 0.9)
108
132
  rspec
109
133
  turnip (~> 1.1.0)
110
134
  turnip-kanban
@@ -0,0 +1,28 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ group 'acceptance-tests' do
5
+ guard 'rspec', cli: '-O .rspec-turnip', turnip: true, spec_paths: ['spec/features'] do
6
+
7
+ watch('spec/turnip_helper.rb') { "spec/features" }
8
+
9
+ watch(%r{^lib/(.+)\.rb$}) { "spec/features" }
10
+
11
+ watch('Assetfile') { 'spec/features' }
12
+
13
+ # Turnip features and steps
14
+ watch(%r{^spec/features/(.+)\.feature$})
15
+ watch(%r{^spec/support/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/features' }
16
+ end
17
+ end
18
+
19
+ group 'unit-tests' do
20
+ guard 'rspec' do
21
+ watch(%r{^spec/.+_spec\.rb$})
22
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
23
+ watch('spec/spec_helper.rb') { "spec" }
24
+
25
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
26
+
27
+ end
28
+ end
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
1
3
  task :features do
2
4
  exec "rspec -O .rspec-turnip spec/features"
3
5
  end
@@ -30,6 +30,7 @@ spec = Gem::Specification.new do |s|
30
30
  s.add_dependency "sass", "~> 3.2.0"
31
31
  s.add_dependency "multi_json", "~> 1.5.0"
32
32
  s.add_dependency "redcarpet", "~> 2.2.2"
33
+ s.add_dependency "kramdown", "~> 1.1.0"
33
34
  s.add_dependency "compass", "~> 0.13.alpha"
34
35
  s.add_dependency "chunky_png", "~> 1.2.0"
35
36
  s.add_dependency "inflecto", "~> 0.0.2"
@@ -37,6 +38,7 @@ spec = Gem::Specification.new do |s|
37
38
  s.add_dependency "rake-pipeline-web-filters", "~> 0.7.0"
38
39
  s.add_dependency "kronic", "~> 1.1.3"
39
40
  s.add_dependency "stamp", "~> 0.5.0"
41
+ s.add_dependency "thin", "~> 1.5.1"
40
42
 
41
43
 
42
44
  s.add_development_dependency "rspec"
@@ -46,5 +48,8 @@ spec = Gem::Specification.new do |s|
46
48
  s.add_development_dependency "pry"
47
49
  s.add_development_dependency "pry-nav"
48
50
  s.add_development_dependency "pry-remote"
51
+ s.add_development_dependency "guard"
52
+ s.add_development_dependency "guard-rspec"
53
+ s.add_development_dependency "rb-fsevent", '~> 0.9'
49
54
 
50
55
  end
data/bin/benoit CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- $:.unshift File.expand_path("../../bundle", __FILE__)
3
- $:.unshift File.expand_path("../../lib", __FILE__)
4
2
  $:.unshift File.expand_path("../../vendor/frontmatter/lib", __FILE__)
5
3
  $:.unshift File.expand_path("../../vendor/rake-pipeline/lib", __FILE__)
4
+ require 'bundler/setup'
6
5
 
7
6
  require 'benoit'
8
7
  require 'gli'
@@ -65,11 +64,30 @@ command :build do |c|
65
64
  end
66
65
  end
67
66
 
68
- desc 'Describe rebuild here'
69
- arg_name 'Describe arguments to rebuild here'
70
- command :rebuild do |c|
67
+ command :server do |c|
68
+
69
+ c.desc 'Name of file containing files that should not be copied or processed to output directory'
70
+ c.default_value '.benoitignore'
71
+ c.flag [:g, :"ignorefile"]
72
+
71
73
  c.action do |global_options,options,args|
72
- puts "rebuild command ran"
74
+
75
+ STDOUT.sync = true
76
+ STDERR.sync = true
77
+
78
+ Benoit::Logger.notice "starting server.."
79
+
80
+ site_path = global_options[:"input-path"] || Dir.pwd
81
+ assetfile_path = File.join(File.expand_path("../../", __FILE__), "Assetfile")
82
+ Dir.chdir(site_path) do
83
+ Benoit.configure do |config|
84
+ puts "specified ignorefile: #{options[:"ignorefile"].inspect}"
85
+ config.ignorefile = options[:"ignorefile"]
86
+ end
87
+ require 'benoit/server'
88
+ project = Benoit::PipelineProject.new(assetfile_path, Benoit.config.output_path, Benoit.config.cache_path)
89
+ Benoit::Server.new(project, daemonize: false, server: 'thin').start
90
+ end
73
91
  end
74
92
  end
75
93
 
@@ -106,7 +124,7 @@ def default_output_path
106
124
  end
107
125
 
108
126
  def default_cache_path(site_name)
109
- File.expand_path("~/.benoit/tmpcache/#{site_name}")
127
+ File.expand_path("/tmp/.benoit/tmpcache/#{site_name}")
110
128
  end
111
129
 
112
130
  post do |global,command,options,args|
@@ -1,10 +1,12 @@
1
1
  require 'stamp'
2
+ require 'cadenza'
2
3
 
3
4
  module Benoit
4
5
  module Cadenza
5
6
 
6
7
  def self.load_output_filters!
7
8
  ::Cadenza::BaseContext.instance_eval File.read(File.join(File.dirname(__FILE__), 'cadenza', 'output_filters.rb'))
9
+ ::Cadenza::BaseContext.instance_eval File.read(File.join(File.dirname(__FILE__), 'cadenza', 'blocks.rb'))
8
10
  end
9
11
 
10
12
  end
@@ -0,0 +1,18 @@
1
+ define_block :times do |context, nodes, parameters|
2
+ from, to, *rest = parameters.map(&:value).map(&:to_i)
3
+
4
+ from, to = 1, from unless to
5
+
6
+ result = ""
7
+
8
+ from.upto(to) do |idx|
9
+ context.push(:counter => idx)
10
+ context.push(:counter0 => idx - from)
11
+ context.push(:first => idx == from)
12
+ context.push(:last => idx == to)
13
+ nodes.each {|child| result << ::Cadenza::TextRenderer.render(child, context) }
14
+ context.pop
15
+ end
16
+
17
+ result
18
+ end
@@ -9,7 +9,7 @@
9
9
  class StandardError
10
10
 
11
11
  def message
12
- @message || "Staticly has encountered an internal error. Please contact @staticlyapp on Twitter to resolve this problem."
12
+ @message# || "Staticly has encountered an internal error. Please contact @staticlyapp on Twitter to resolve this problem."
13
13
  end
14
14
 
15
15
  def type
@@ -31,6 +31,10 @@ module Benoit
31
31
  @original_error = original_error
32
32
  end
33
33
 
34
+ def message
35
+ @message || (@original_error && @original_error.message)
36
+ end
37
+
34
38
  def to_json
35
39
  { line_no: @line, message: @message, path: @file_path, original_error: @original_error, type: "error" }.to_json
36
40
  end
@@ -27,16 +27,15 @@ module Benoit
27
27
 
28
28
  def generate_output(inputs, output)
29
29
  inputs.each do |input|
30
- page = current_site[input.path]
31
- content = build_output(page, input) if builder
32
- output.write(content || page["content"])
30
+ content = build_output(input) if builder
31
+ output.write(content || input.read)
33
32
  end
34
33
  end
35
34
 
36
35
  private
37
36
 
38
- def build_output(page, input)
39
- builder.(page, input)
37
+ def build_output(input)
38
+ builder.(input)
40
39
  end
41
40
 
42
41
  end
@@ -13,7 +13,7 @@ class Benoit::Filters::CadenzaFilter < Rake::Pipeline::Filter
13
13
 
14
14
  def generate_output(inputs, output)
15
15
 
16
- site_context = current_site.to_context
16
+ # site_context = current_site.to_context
17
17
 
18
18
  inputs.each do |input|
19
19
  load_paths = [input.root, Dir.pwd, "#{Dir.pwd}/_layouts"]
@@ -24,20 +24,21 @@ class Benoit::Filters::CadenzaFilter < Rake::Pipeline::Filter
24
24
  ::Cadenza::BaseContext.add_load_path load_path
25
25
  end
26
26
 
27
- page = current_site[input.path].to_hash
27
+ # page = current_site[input.path].to_hash
28
28
 
29
29
  # Leave the original page for paginated pages blank
30
30
  # otherwise we will get an "iteration reached an end" error
31
31
  # from trying to iterate past the end of the enumerator
32
- if input.path !~ /\d+.html/ && page.keys.any? { |key| key =~ /\w+_per_page/ }
33
- output.write("")
34
- next
35
- end
32
+ # if input.path !~ /\d+.html/ && page.keys.any? { |key| key =~ /\w+_per_page/ }
33
+ # output.write("")
34
+ # next
35
+ # end
36
36
 
37
- context_hash = {
38
- "site" => site_context,
39
- "page" => page
40
- }
37
+ # context_hash = {
38
+ # "site" => site_context,
39
+ # "page" => page
40
+ # }
41
+ context_hash = {}
41
42
 
42
43
  begin
43
44
  compiled = ::Cadenza.render_template input.path, context_hash
@@ -45,11 +46,15 @@ class Benoit::Filters::CadenzaFilter < Rake::Pipeline::Filter
45
46
  error = Benoit::FileMissingError.new(ex.message, nil, input.path, ex)
46
47
  raise error
47
48
  rescue ::Cadenza::FilterNotDefinedError => ex
48
- missing_filter = ex.message.scan(/undefined filter '([\w\-_]*)'/).flatten.first
49
+ missing_filter = ex.to_s.scan(/undefined filter '([\w\-]*)'/).flatten.first
49
50
  error = Benoit::CompilerError.new(nil, input.path, ex)
50
51
  error.message = "You used a filter named #{missing_filter.inspect}, but I could not find it. Maybe it's misspelled?"
51
52
  raise error
52
- rescue ::Cadenza::Error => ex
53
+ rescue ::Cadenza::BlockNotDefinedError => ex
54
+ missing_block = ex.to_s.scan(/undefined block '([\w\-]*)'/).flatten.first
55
+ error = Benoit::CompilerError.new(nil, input.path, ex)
56
+ error.message = "You used a block named #{missing_block.inspect}, but I could not find it. Maybe it's misspelled?"
57
+ raise error
53
58
  end
54
59
 
55
60
  output.write compiled
@@ -59,14 +64,12 @@ class Benoit::Filters::CadenzaFilter < Rake::Pipeline::Filter
59
64
 
60
65
  def page_layouts_for_input(input)
61
66
  @page_layouts[input.path] ||=
62
- FindsLayoutsForTemplate(input.path, root: input.root, load_paths: ["_layouts"])
67
+ FindsLayoutsForTemplate(input, root: input.root, load_paths: ["_layouts"])
63
68
  end
64
69
 
65
70
  def additional_dependencies(input=nil)
66
71
  if input
67
- Dir["**/*.markdown"].map do |f|
68
- f.gsub input.root, ""
69
- end
72
+ page_layouts_for_input(input)
70
73
  else
71
74
  []
72
75
  end
@@ -1,4 +1,6 @@
1
1
  require 'redcarpet'
2
+ require 'kramdown'
3
+ require 'benoit/utils/finds_layouts_for_template'
2
4
 
3
5
  module Benoit::Filters
4
6
  class MarkdownFilter < BaseFilter
@@ -7,12 +9,42 @@ module Benoit::Filters
7
9
  path.sub(/\.(md|mdown|mkdown|markdown)$/, '.html')
8
10
  end
9
11
 
10
- build_output do |page|
12
+ build_output do |input|
13
+ input_content = input.read
14
+ layout = Benoit::Utils::FindsLayoutsForTemplate.first_layout(input_content)
15
+ preserving_layout(layout, input_content) do |content|
16
+ render_markdown(:redcarpet, content)
17
+ end
18
+ end
19
+
20
+ def self.preserving_layout(layout, content, &block)
21
+ content = extract_layout(content) if layout
22
+ output = block.call(content)
23
+ output = prepend_layout(output, layout) if layout
24
+ output
25
+ end
11
26
 
12
- markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, fenced_code_blocks: true)
13
- rendered = markdown.render(page["content"])
27
+ def self.extract_layout(content)
28
+ first_nonblank_line =
29
+ content.lines.find_index do |line|
30
+ line !~ /extends/ and line.strip != ""
31
+ end
32
+ content.lines.to_a[first_nonblank_line..-1].join("")
33
+ end
34
+
35
+ def self.prepend_layout(final_content, layout)
36
+ extends_line = %{{% extends "#{layout}" %}\n\n}
37
+ %{#{extends_line}#{final_content}}
38
+ end
14
39
 
15
- page["content"] = rendered
40
+ def self.render_markdown(engine, content, options={})
41
+ case engine
42
+ when :redcarpet
43
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, fenced_code_blocks: true, filter_html: true)
44
+ markdown.render(content)
45
+ when :kramdown
46
+ Kramdown::Document.new(content).to_html
47
+ end
16
48
  end
17
49
 
18
50
  end