lib/jekyll/utils.rb in jekyll-3.5.2 vs lib/jekyll/utils.rb in jekyll-3.6.0.pre.beta1
- old
+ new
@@ -1,12 +1,15 @@
+# frozen_string_literal: true
+
module Jekyll
module Utils
extend self
autoload :Ansi, "jekyll/utils/ansi"
autoload :Exec, "jekyll/utils/exec"
autoload :Platforms, "jekyll/utils/platforms"
+ autoload :Rouge, "jekyll/utils/rouge"
autoload :WinTZ, "jekyll/utils/win_tz"
# Constants for use in #slugify
SLUGIFY_MODES = %w(raw default pretty ascii).freeze
SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
@@ -245,19 +248,22 @@
# add_permalink_suffix("/:basename", "/:year/:month/:title")
# # => "/:basename"
#
# Returns the updated permalink template
def add_permalink_suffix(template, permalink_style)
+ template = template.dup
+
case permalink_style
when :pretty
template << "/"
when :date, :ordinal, :none
template << ":output_ext"
else
template << "/" if permalink_style.to_s.end_with?("/")
template << ":output_ext" if permalink_style.to_s.end_with?(":output_ext")
end
+
template
end
# Work the same way as Dir.glob but seperating the input into two parts
# ('dir' + '/' + 'pattern') to make sure the first part('dir') does not act
@@ -294,10 +300,10 @@
# Returns merged option hash for File.read of self.site (if exists)
# and a given param
def merged_file_read_opts(site, opts)
merged = (site ? site.file_read_opts : {}).merge(opts)
if merged["encoding"] && !merged["encoding"].start_with?("bom|")
- merged["encoding"].insert(0, "bom|")
+ merged["encoding"] = "bom|#{merged["encoding"]}"
end
merged
end
private