bridgetown-core 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/bridgetown-core.gemspec +0 -1
  3. data/lib/bridgetown-core.rb +11 -22
  4. data/lib/bridgetown-core/cleaner.rb +2 -2
  5. data/lib/bridgetown-core/collection.rb +14 -11
  6. data/lib/bridgetown-core/commands/build.rb +0 -11
  7. data/lib/bridgetown-core/commands/concerns/git_helpers.rb +20 -0
  8. data/lib/bridgetown-core/commands/configure.rb +4 -3
  9. data/lib/bridgetown-core/commands/doctor.rb +1 -19
  10. data/lib/bridgetown-core/commands/new.rb +6 -6
  11. data/lib/bridgetown-core/commands/plugins.rb +14 -13
  12. data/lib/bridgetown-core/commands/serve.rb +0 -14
  13. data/lib/bridgetown-core/commands/webpack.rb +75 -0
  14. data/lib/bridgetown-core/commands/webpack/enable-postcss.rb +12 -0
  15. data/lib/bridgetown-core/commands/webpack/setup.rb +4 -0
  16. data/lib/bridgetown-core/commands/webpack/update.rb +3 -0
  17. data/lib/bridgetown-core/commands/webpack/webpack.config.js +18 -0
  18. data/lib/{site_template/webpack.config.js.erb → bridgetown-core/commands/webpack/webpack.defaults.js.erb} +25 -11
  19. data/lib/bridgetown-core/component.rb +183 -0
  20. data/lib/bridgetown-core/concerns/front_matter_importer.rb +52 -0
  21. data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
  22. data/lib/bridgetown-core/concerns/site/configurable.rb +3 -7
  23. data/lib/bridgetown-core/concerns/site/content.rb +2 -3
  24. data/lib/bridgetown-core/concerns/site/localizable.rb +3 -5
  25. data/lib/bridgetown-core/concerns/site/processable.rb +5 -4
  26. data/lib/bridgetown-core/concerns/site/writable.rb +1 -1
  27. data/lib/bridgetown-core/concerns/validatable.rb +1 -5
  28. data/lib/bridgetown-core/configuration.rb +22 -14
  29. data/lib/bridgetown-core/configurations/bt-postcss.rb +6 -6
  30. data/lib/bridgetown-core/configurations/netlify.rb +1 -0
  31. data/lib/bridgetown-core/configurations/tailwindcss.rb +6 -6
  32. data/lib/bridgetown-core/converter.rb +9 -0
  33. data/lib/bridgetown-core/converters/erb_templates.rb +51 -35
  34. data/lib/bridgetown-core/converters/liquid_templates.rb +1 -1
  35. data/lib/bridgetown-core/converters/markdown.rb +1 -1
  36. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +2 -38
  37. data/lib/bridgetown-core/converters/ruby_templates.rb +17 -0
  38. data/lib/bridgetown-core/converters/smartypants.rb +3 -1
  39. data/lib/bridgetown-core/core_ext/psych.rb +19 -0
  40. data/lib/bridgetown-core/document.rb +3 -2
  41. data/lib/bridgetown-core/drops/relations_drop.rb +23 -0
  42. data/lib/bridgetown-core/drops/resource_drop.rb +3 -1
  43. data/lib/bridgetown-core/drops/unified_payload_drop.rb +1 -0
  44. data/lib/bridgetown-core/entry_filter.rb +7 -5
  45. data/lib/bridgetown-core/filters.rb +1 -25
  46. data/lib/bridgetown-core/filters/from_liquid.rb +23 -0
  47. data/lib/bridgetown-core/filters/url_filters.rb +12 -0
  48. data/lib/bridgetown-core/frontmatter_defaults.rb +1 -1
  49. data/lib/bridgetown-core/generators/prototype_generator.rb +25 -4
  50. data/lib/bridgetown-core/helpers.rb +48 -9
  51. data/lib/bridgetown-core/layout.rb +52 -20
  52. data/lib/bridgetown-core/model/origin.rb +1 -1
  53. data/lib/bridgetown-core/model/{file_origin.rb → repo_origin.rb} +33 -26
  54. data/lib/bridgetown-core/page.rb +2 -1
  55. data/lib/bridgetown-core/plugin_manager.rb +1 -1
  56. data/lib/bridgetown-core/publisher.rb +2 -2
  57. data/lib/bridgetown-core/reader.rb +13 -11
  58. data/lib/bridgetown-core/readers/data_reader.rb +2 -1
  59. data/lib/bridgetown-core/readers/defaults_reader.rb +1 -1
  60. data/lib/bridgetown-core/readers/layout_reader.rb +1 -1
  61. data/lib/bridgetown-core/readers/page_reader.rb +1 -0
  62. data/lib/bridgetown-core/readers/post_reader.rb +5 -4
  63. data/lib/bridgetown-core/regenerator.rb +1 -1
  64. data/lib/bridgetown-core/related_posts.rb +8 -5
  65. data/lib/bridgetown-core/renderer.rb +1 -1
  66. data/lib/bridgetown-core/resource/base.rb +80 -26
  67. data/lib/bridgetown-core/resource/permalink_processor.rb +1 -1
  68. data/lib/bridgetown-core/resource/relations.rb +132 -0
  69. data/lib/bridgetown-core/resource/taxonomy_term.rb +10 -1
  70. data/lib/bridgetown-core/resource/taxonomy_type.rb +9 -0
  71. data/lib/bridgetown-core/resource/transformer.rb +18 -14
  72. data/lib/bridgetown-core/ruby_template_view.rb +7 -11
  73. data/lib/bridgetown-core/site.rb +4 -5
  74. data/lib/bridgetown-core/tags/highlight.rb +2 -15
  75. data/lib/bridgetown-core/tags/include.rb +1 -1
  76. data/lib/bridgetown-core/tags/post_url.rb +2 -2
  77. data/lib/bridgetown-core/utils.rb +9 -3
  78. data/lib/bridgetown-core/utils/require_gems.rb +60 -0
  79. data/lib/bridgetown-core/utils/ruby_exec.rb +6 -9
  80. data/lib/bridgetown-core/utils/ruby_front_matter.rb +39 -0
  81. data/lib/bridgetown-core/version.rb +2 -2
  82. data/lib/bridgetown-core/watcher.rb +2 -1
  83. data/lib/bridgetown-core/yaml_parser.rb +22 -0
  84. data/lib/site_template/config/.keep +0 -0
  85. data/lib/site_template/package.json.erb +4 -4
  86. data/lib/site_template/plugins/site_builder.rb +1 -1
  87. data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +1 -1
  88. metadata +21 -23
  89. data/lib/bridgetown-core/external.rb +0 -58
  90. data/lib/bridgetown-core/path_manager.rb +0 -31
  91. data/lib/bridgetown-core/readers/static_file_reader.rb +0 -25
  92. data/lib/bridgetown-core/utils/platforms.rb +0 -81
  93. data/lib/bridgetown-core/utils/thread_event.rb +0 -31
@@ -11,7 +11,7 @@ module Bridgetown
11
11
  end
12
12
 
13
13
  def no_layout?
14
- data["layout"] == "none" || data["layout"] == false
14
+ data.layout.nil? || data.layout == "none" || data.layout == false
15
15
  end
16
16
  end
17
17
  end
@@ -18,18 +18,13 @@ class Bridgetown::Site
18
18
  @root_dir = File.expand_path(config["root_dir"]).freeze
19
19
  @source = File.expand_path(config["source"]).freeze
20
20
  @dest = File.expand_path(config["destination"]).freeze
21
- @cache_dir = in_root_dir(config["cache_dir"]).freeze
22
-
23
- %w(lsi highlighter baseurl exclude include future unpublished
24
- limit_posts keep_files).each do |opt|
25
- send("#{opt}=", config[opt])
26
- end
27
21
 
28
22
  configure_cache
29
23
  configure_component_paths
30
24
  configure_include_paths
31
25
  configure_file_read_opts
32
26
 
27
+ self.baseurl = config.baseurl
33
28
  self.permalink_style = (config["permalink"] || "pretty").to_sym
34
29
 
35
30
  @config
@@ -153,7 +148,8 @@ class Bridgetown::Site
153
148
 
154
149
  # Disable Marshaling cache to disk in Safe Mode
155
150
  def configure_cache
156
- Bridgetown::Cache.cache_dir = in_root_dir(config["cache_dir"], "Bridgetown/Cache")
151
+ @cache_dir = in_root_dir(config["cache_dir"]).freeze
152
+ Bridgetown::Cache.cache_dir = File.join(cache_dir, "Bridgetown/Cache")
157
153
  Bridgetown::Cache.disable_disk_cache! if config["disable_disk_cache"]
158
154
  end
159
155
 
@@ -173,9 +173,8 @@ class Bridgetown::Site
173
173
  documents.select(&:write?)
174
174
  end
175
175
 
176
- # Get all documents.
177
- # @return [Array<Document>] an array of documents from the
178
- # configuration
176
+ # Get all loaded resources.
177
+ # @return [Array<Bridgetown::Resource::Base>] an array of resources
179
178
  def resources
180
179
  collections.each_with_object(Set.new) do |(_, collection), set|
181
180
  set.merge(collection.resources)
@@ -5,13 +5,11 @@ class Bridgetown::Site
5
5
  # Returns the current and/or default configured locale
6
6
  # @return String
7
7
  def locale
8
- if @locale
9
- @locale
10
- else
11
- @locale = ENV.fetch("BRIDGETOWN_LOCALE", config[:default_locale]).to_sym
8
+ @locale ||= begin
9
+ locale = ENV.fetch("BRIDGETOWN_LOCALE", config[:default_locale]).to_sym
12
10
  I18n.load_path << Dir[in_source_dir("_locales") + "/*.yml"]
13
11
  I18n.available_locales = config[:available_locales]
14
- I18n.default_locale = @locale
12
+ I18n.default_locale = locale
15
13
  end
16
14
  end
17
15
 
@@ -42,8 +42,6 @@ class Bridgetown::Site
42
42
  @liquid_renderer.reset
43
43
  frontmatter_defaults.reset
44
44
 
45
- raise ArgumentError, "limit_posts must be a non-negative number" if limit_posts.negative?
46
-
47
45
  Bridgetown::Cache.clear_if_config_changed config
48
46
  Bridgetown::Hooks.trigger :site, :after_reset, self
49
47
  end
@@ -61,8 +59,11 @@ class Bridgetown::Site
61
59
 
62
60
  # Limits the current posts; removes the posts which exceed the limit_posts
63
61
  def limit_posts!
64
- if limit_posts.positive?
65
- limit = posts.docs.length < limit_posts ? posts.docs.length : limit_posts
62
+ if config.limit_posts.positive?
63
+ Bridgetown::Deprecator.deprecation_message(
64
+ "The limit_posts config option will be removed prior to Bridgetown 1.0"
65
+ )
66
+ limit = posts.docs.length < config.limit_posts ? posts.docs.length : config.limit_posts
66
67
  posts.docs = posts.docs[-limit, limit]
67
68
  end
68
69
  end
@@ -21,7 +21,7 @@ class Bridgetown::Site
21
21
  end
22
22
 
23
23
  # Yields all content objects while looping through {#pages},
24
- # {#static_files_to_write}, and {#docs_to_write}.
24
+ # {#static_files_to_write}, {#docs_to_write}, {#resources_to_write}.
25
25
  #
26
26
  # @yieldparam item [Document, Page, StaticFile]
27
27
  #
@@ -3,10 +3,6 @@
3
3
  module Bridgetown
4
4
  # TODO: to be retired once the Resource engine is made official
5
5
  module Validatable
6
- # FIXME: there should be ONE TRUE METHOD to read the YAML frontmatter
7
- # in the entire project. Both this and the equivalent Document method
8
- # should be extracted and generalized.
9
- #
10
6
  # Read the YAML frontmatter.
11
7
  #
12
8
  # base - The String path to the dir containing the file.
@@ -23,7 +19,7 @@ module Bridgetown
23
19
  **Utils.merged_file_read_opts(site, opts))
24
20
  if content =~ Document::YAML_FRONT_MATTER_REGEXP
25
21
  self.content = $POSTMATCH
26
- self.data = SafeYAML.load(Regexp.last_match(1))&.with_dot_access
22
+ self.data = YAMLParser.load(Regexp.last_match(1))&.with_dot_access
27
23
  end
28
24
  rescue Psych::SyntaxError => e
29
25
  Bridgetown.logger.warn "YAML Exception reading #{filename}: #{e.message}"
@@ -74,15 +74,16 @@ module Bridgetown
74
74
  },
75
75
 
76
76
  "kramdown" => {
77
- "auto_ids" => true,
78
- "toc_levels" => (1..6).to_a,
79
- "entity_output" => "as_char",
80
- "smart_quotes" => "lsquo,rsquo,ldquo,rdquo",
81
- "input" => "GFM",
82
- "hard_wrap" => false,
83
- "guess_lang" => true,
84
- "footnote_nr" => 1,
85
- "show_warnings" => false,
77
+ "auto_ids" => true,
78
+ "toc_levels" => (1..6).to_a,
79
+ "entity_output" => "as_char",
80
+ "smart_quotes" => "lsquo,rsquo,ldquo,rdquo",
81
+ "input" => "GFM",
82
+ "hard_wrap" => false,
83
+ "guess_lang" => true,
84
+ "footnote_nr" => 1,
85
+ "show_warnings" => false,
86
+ "include_extraction_tags" => false,
86
87
  },
87
88
  }.each_with_object(Configuration.new) { |(k, v), hsh| hsh[k] = v.freeze }.freeze
88
89
 
@@ -117,7 +118,7 @@ module Bridgetown
117
118
  # override - the command-line options hash
118
119
  #
119
120
  # Returns the path to the Bridgetown root directory
120
- def root_dir(override)
121
+ def root_dir(override = "")
121
122
  get_config_value_with_override("root_dir", override)
122
123
  end
123
124
 
@@ -126,7 +127,7 @@ module Bridgetown
126
127
  # override - the command-line options hash
127
128
  #
128
129
  # Returns the path to the Bridgetown source directory
129
- def source(override)
130
+ def source(override = "")
130
131
  get_config_value_with_override("source", override)
131
132
  end
132
133
 
@@ -143,10 +144,10 @@ module Bridgetown
143
144
  def safe_load_file(filename)
144
145
  case File.extname(filename)
145
146
  when %r!\.toml!i
146
- Bridgetown::External.require_with_graceful_fail("tomlrb") unless defined?(Tomlrb)
147
+ Bridgetown::Utils::RequireGems.require_with_graceful_fail("tomlrb") unless defined?(Tomlrb)
147
148
  Tomlrb.load_file(filename)
148
149
  when %r!\.ya?ml!i
149
- SafeYAML.load_file(filename) || {}
150
+ YAMLParser.load_file(filename) || {}
150
151
  else
151
152
  raise ArgumentError,
152
153
  "No parser for '#{filename}' is available. Use a .y(a)ml or .toml file instead."
@@ -225,7 +226,7 @@ module Bridgetown
225
226
  raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow
226
227
  end
227
228
 
228
- Bridgetown.logger.info "Configuration file:", file
229
+ Bridgetown.logger.debug "Configuration file:", file
229
230
  next_config
230
231
  rescue SystemCallError
231
232
  if @default_config_file ||= nil
@@ -339,5 +340,12 @@ module Bridgetown
339
340
 
340
341
  self
341
342
  end
343
+
344
+ # Whether or not PostCSS is being used to process stylesheets.
345
+ #
346
+ # @return [Boolean] true if `postcss.config.js` exists, false if not
347
+ def uses_postcss?
348
+ File.exist?(Bridgetown.sanitized_path(root_dir, "postcss.config.js"))
349
+ end
342
350
  end
343
351
  end
@@ -4,23 +4,23 @@
4
4
 
5
5
  TEMPLATE_PATH = File.expand_path("./bt-postcss", __dir__)
6
6
 
7
- begin
8
- find_in_source_paths("postcss.config.js")
9
- rescue Thor::Error
7
+ unless File.exist?("postcss.config.js")
10
8
  error_message = "#{"postcss.config.js".bold} not found. Please configure postcss in your project."
11
9
 
12
10
  @logger.error "\nError:".red, "🚨 #{error_message}"
13
- @logger.info "\nFor new projects, you can use #{"bridgetown new my_project --use-postcss".bold.blue}\n"
11
+ @logger.info "\nRun #{"bridgetown webpack enable-postcss".bold.blue} to set it up.\n"
14
12
 
15
13
  return
16
14
  end
17
15
 
16
+ confirm = ask "This configuration will ovewrite your existing #{"postcss.config.js".bold.white}. Would you like to continue? [Yn]"
17
+ return unless confirm.casecmp?("Y")
18
+
18
19
  plugins = %w(postcss-easy-import postcss-mixins postcss-color-function cssnano)
19
20
 
20
21
  say "Adding the following PostCSS plugins: #{plugins.join(' | ')}", :green
21
22
  run "yarn add -D #{plugins.join(' ')}"
22
23
 
23
- remove_file "postcss.config.js"
24
- copy_file "#{TEMPLATE_PATH}/postcss.config.js", "postcss.config.js"
24
+ copy_file "#{TEMPLATE_PATH}/postcss.config.js", "postcss.config.js", force: true
25
25
 
26
26
  # rubocop:enable all
@@ -4,3 +4,4 @@ TEMPLATE_PATH = File.expand_path("./netlify", __dir__)
4
4
 
5
5
  copy_file "#{TEMPLATE_PATH}/netlify.toml", "netlify.toml"
6
6
  copy_file "#{TEMPLATE_PATH}/netlify.sh", "bin/netlify.sh"
7
+ `chmod a+x ./bin/netlify.sh`
@@ -4,22 +4,22 @@
4
4
 
5
5
  TEMPLATE_PATH = File.expand_path("./tailwindcss", __dir__)
6
6
 
7
- begin
8
- find_in_source_paths("postcss.config.js")
9
- rescue Thor::Error
7
+ unless File.exist?("postcss.config.js")
10
8
  error_message = "#{"postcss.config.js".bold} not found. Please configure postcss in your project."
11
9
 
12
10
  @logger.error "\nError:".red, "🚨 #{error_message}"
13
- @logger.info "\nFor new projects, you can use #{"bridgetown new my_project --use-postcss".bold.blue}\n"
11
+ @logger.info "\nRun #{"bridgetown webpack enable-postcss".bold.blue} to set it up.\n"
14
12
 
15
13
  return
16
14
  end
17
15
 
16
+ confirm = ask "This configuration will ovewrite your existing #{"postcss.config.js".bold.white}. Would you like to continue? [Yn]"
17
+ return unless confirm.casecmp?("Y")
18
+
18
19
  run "yarn add -D tailwindcss"
19
20
  run "npx tailwindcss init"
20
21
 
21
- remove_file "postcss.config.js"
22
- copy_file "#{TEMPLATE_PATH}/postcss.config.js", "postcss.config.js"
22
+ copy_file "#{TEMPLATE_PATH}/postcss.config.js", "postcss.config.js", force: true
23
23
 
24
24
  prepend_to_file "frontend/styles/index.css",
25
25
  File.read("#{TEMPLATE_PATH}/css_imports.css")
@@ -53,6 +53,15 @@ module Bridgetown
53
53
  ".html"
54
54
  end
55
55
 
56
+ def line_start(convertible)
57
+ if convertible.is_a?(Bridgetown::Resource::Base) &&
58
+ convertible.model.origin.respond_to?(:front_matter_line_count)
59
+ convertible.model.origin.front_matter_line_count + 4
60
+ else
61
+ 1
62
+ end
63
+ end
64
+
56
65
  def inspect
57
66
  "#<#{self.class}#{self.class.extname_list ? " #{self.class.extname_list.join(", ")}" : nil}>"
58
67
  end
@@ -3,14 +3,26 @@
3
3
  require "tilt/erubi"
4
4
 
5
5
  module Bridgetown
6
- class ERBBuffer < String
7
- def concat_to_s(input)
8
- concat input.to_s
6
+ class OutputBuffer < ActiveSupport::SafeBuffer
7
+ def initialize(*)
8
+ super
9
+ encode!
9
10
  end
10
11
 
11
- alias_method :safe_append=, :concat_to_s
12
- alias_method :append=, :concat_to_s
13
- alias_method :safe_expr_append=, :concat_to_s
12
+ def <<(value)
13
+ return self if value.nil?
14
+
15
+ super(value.to_s)
16
+ end
17
+ alias_method :append=, :<<
18
+
19
+ def safe_expr_append=(val)
20
+ return self if val.nil? # rubocop:disable Lint/ReturnInVoidContext
21
+
22
+ safe_concat val.to_s
23
+ end
24
+
25
+ alias_method :safe_append=, :safe_concat
14
26
  end
15
27
 
16
28
  class ERBEngine < Erubi::Engine
@@ -22,24 +34,47 @@ module Bridgetown
22
34
  @src << ";" unless code[Erubi::RANGE_LAST] == "\n"
23
35
  end
24
36
 
37
+ def add_text(text)
38
+ return if text.empty?
39
+
40
+ src << bufvar << ".safe_append='"
41
+ src << text.gsub(%r{['\\]}, '\\\\\&')
42
+ src << "'.freeze;"
43
+ end
44
+
25
45
  # pulled from Rails' ActionView
26
46
  BLOCK_EXPR = %r!\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z!.freeze
27
47
 
28
48
  def add_expression(indicator, code)
49
+ src << bufvar << if (indicator == "==") || @escape
50
+ ".safe_expr_append="
51
+ else
52
+ ".append="
53
+ end
54
+
29
55
  if BLOCK_EXPR.match?(code)
30
- src << "#{@bufvar}.append= " << code
56
+ src << " " << code
31
57
  else
32
- super
58
+ src << "(" << code << ");"
33
59
  end
34
60
  end
61
+ end
35
62
 
36
- # Don't allow == to output escaped strings, as that's the opposite of Rails
37
- def add_expression_result_escaped(code)
38
- add_expression_result(code)
63
+ module ERBCapture
64
+ def capture(*args)
65
+ previous_buffer_state = @_erbout
66
+ @_erbout = OutputBuffer.new
67
+ result = yield(*args)
68
+ result = @_erbout.presence || result
69
+ @_erbout = previous_buffer_state
70
+
71
+ result.is_a?(String) ? ERB::Util.h(result) : result
39
72
  end
40
73
  end
41
74
 
42
75
  class ERBView < RubyTemplateView
76
+ include ERBCapture
77
+
43
78
  def h(input)
44
79
  Erubi.h(input)
45
80
  end
@@ -55,30 +90,10 @@ module Bridgetown
55
90
  Tilt::ErubiTemplate.new(
56
91
  site.in_source_dir(site.config[:partials_dir], "#{partial_name}.erb"),
57
92
  outvar: "@_erbout",
58
- bufval: "Bridgetown::ERBBuffer.new",
93
+ bufval: "Bridgetown::OutputBuffer.new",
59
94
  engine_class: ERBEngine
60
95
  ).render(self, options)
61
96
  end
62
-
63
- def markdownify(input = nil, &block)
64
- content = Bridgetown::Utils.reindent_for_markdown(
65
- block.nil? ? input.to_s : capture(&block)
66
- )
67
- converter = site.find_converter_instance(Bridgetown::Converters::Markdown)
68
- result = converter.convert(content).strip
69
- result.respond_to?(:html_safe) ? result.html_safe : result
70
- end
71
-
72
- def capture(*args, &block)
73
- return capture_in_view_component(*args, &block) if @in_view_component
74
-
75
- previous_buffer_state = @_erbout
76
- @_erbout = ERBBuffer.new
77
- result = yield(*args)
78
- @_erbout = previous_buffer_state
79
-
80
- result.respond_to?(:html_safe) ? result.html_safe : result
81
- end
82
97
  end
83
98
 
84
99
  module Converters
@@ -89,7 +104,7 @@ module Bridgetown
89
104
  # Logic to do the ERB content conversion.
90
105
  #
91
106
  # @param content [String] Content of the file (without front matter).
92
- # @params convertible [Bridgetown::Page, Bridgetown::Document, Bridgetown::Layout]
107
+ # @param convertible [Bridgetown::Page, Bridgetown::Document, Bridgetown::Layout]
93
108
  # The instantiated object which is processing the file.
94
109
  #
95
110
  # @return [String] The converted content.
@@ -100,14 +115,15 @@ module Bridgetown
100
115
 
101
116
  erb_renderer = Tilt::ErubiTemplate.new(
102
117
  convertible.relative_path,
118
+ line_start(convertible),
103
119
  outvar: "@_erbout",
104
- bufval: "Bridgetown::ERBBuffer.new",
120
+ bufval: "Bridgetown::OutputBuffer.new",
105
121
  engine_class: ERBEngine
106
122
  ) { content }
107
123
 
108
124
  if convertible.is_a?(Bridgetown::Layout)
109
125
  erb_renderer.render(erb_view) do
110
- convertible.current_document_output
126
+ convertible.current_document_output.html_safe
111
127
  end
112
128
  else
113
129
  erb_renderer.render(erb_view)
@@ -18,7 +18,7 @@ module Bridgetown
18
18
  # Logic to do the Liquid content conversion.
19
19
  #
20
20
  # @param content [String] Content of the file (without front matter).
21
- # @params convertible [Bridgetown::Page, Bridgetown::Document, Bridgetown::Layout]
21
+ # @param convertible [Bridgetown::Page, Bridgetown::Document, Bridgetown::Layout]
22
22
  # The instantiated object which is processing the file.
23
23
  #
24
24
  # @return [String] The converted content.
@@ -69,7 +69,7 @@ module Bridgetown
69
69
  end
70
70
  else
71
71
  output = @parser.convert(content)
72
- if @parser.respond_to?(:extractions)
72
+ if convertible && @parser.respond_to?(:extractions)
73
73
  convertible.data.markdown_extractions = @parser.extractions
74
74
  end
75
75
  output