require external library only if necessary (#6596)
Merge pull request 6596
This commit is contained in:
parent
9cc6e2a1d1
commit
9a88900246
|
@ -14,7 +14,9 @@ module Jekyll
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
def initialize(config)
|
def initialize(config)
|
||||||
Jekyll::External.require_with_graceful_fail "kramdown"
|
unless defined?(Kramdown)
|
||||||
|
Jekyll::External.require_with_graceful_fail "kramdown"
|
||||||
|
end
|
||||||
@main_fallback_highlighter = config["highlighter"] || "rouge"
|
@main_fallback_highlighter = config["highlighter"] || "rouge"
|
||||||
@config = config["kramdown"] || {}
|
@config = config["kramdown"] || {}
|
||||||
@highlighter = nil
|
@highlighter = nil
|
||||||
|
|
|
@ -5,7 +5,9 @@ module Jekyll
|
||||||
class Markdown
|
class Markdown
|
||||||
class RDiscountParser
|
class RDiscountParser
|
||||||
def initialize(config)
|
def initialize(config)
|
||||||
Jekyll::External.require_with_graceful_fail "rdiscount"
|
unless defined?(RDiscount)
|
||||||
|
Jekyll::External.require_with_graceful_fail "rdiscount"
|
||||||
|
end
|
||||||
@config = config
|
@config = config
|
||||||
@rdiscount_extensions = @config["rdiscount"]["extensions"].map(&:to_sym)
|
@rdiscount_extensions = @config["rdiscount"]["extensions"].map(&:to_sym)
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,9 @@ class Jekyll::Converters::Markdown::RedcarpetParser
|
||||||
module WithPygments
|
module WithPygments
|
||||||
include CommonMethods
|
include CommonMethods
|
||||||
def block_code(code, lang)
|
def block_code(code, lang)
|
||||||
Jekyll::External.require_with_graceful_fail("pygments")
|
unless defined?(Pygments)
|
||||||
|
Jekyll::External.require_with_graceful_fail("pygments")
|
||||||
|
end
|
||||||
lang = lang && lang.split.first || "text"
|
lang = lang && lang.split.first || "text"
|
||||||
add_code_tags(
|
add_code_tags(
|
||||||
Pygments.highlight(
|
Pygments.highlight(
|
||||||
|
@ -60,7 +62,9 @@ class Jekyll::Converters::Markdown::RedcarpetParser
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(config)
|
def initialize(config)
|
||||||
Jekyll::External.require_with_graceful_fail("redcarpet")
|
unless defined?(Redcarpet)
|
||||||
|
Jekyll::External.require_with_graceful_fail("redcarpet")
|
||||||
|
end
|
||||||
@config = config
|
@config = config
|
||||||
@redcarpet_extensions = {}
|
@redcarpet_extensions = {}
|
||||||
@config["redcarpet"]["extensions"].each do |e|
|
@config["redcarpet"]["extensions"].each do |e|
|
||||||
|
|
|
@ -20,7 +20,9 @@ module Jekyll
|
||||||
priority :low
|
priority :low
|
||||||
|
|
||||||
def initialize(config)
|
def initialize(config)
|
||||||
Jekyll::External.require_with_graceful_fail "kramdown"
|
unless defined?(Kramdown)
|
||||||
|
Jekyll::External.require_with_graceful_fail "kramdown"
|
||||||
|
end
|
||||||
@config = config["kramdown"].dup || {}
|
@config = config["kramdown"].dup || {}
|
||||||
@config[:input] = :SmartyPants
|
@config[:input] = :SmartyPants
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,7 +38,7 @@ module Jekyll
|
||||||
|
|
||||||
def configure_sass
|
def configure_sass
|
||||||
return unless sass_path
|
return unless sass_path
|
||||||
Jekyll::External.require_with_graceful_fail "sass"
|
External.require_with_graceful_fail("sass") unless defined?(Sass)
|
||||||
Sass.load_paths << sass_path
|
Sass.load_paths << sass_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Jekyll
|
||||||
module Rouge
|
module Rouge
|
||||||
|
|
||||||
def self.html_formatter(*args)
|
def self.html_formatter(*args)
|
||||||
Jekyll::External.require_with_graceful_fail("rouge")
|
Jekyll::External.require_with_graceful_fail("rouge") unless defined?(::Rouge)
|
||||||
if old_api?
|
if old_api?
|
||||||
::Rouge::Formatters::HTML.new(*args)
|
::Rouge::Formatters::HTML.new(*args)
|
||||||
else
|
else
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns a string that ultimately re-defines ENV["TZ"] in Windows
|
# Returns a string that ultimately re-defines ENV["TZ"] in Windows
|
||||||
def calculate(timezone)
|
def calculate(timezone)
|
||||||
External.require_with_graceful_fail("tzinfo")
|
External.require_with_graceful_fail("tzinfo") unless defined?(TZInfo)
|
||||||
tz = TZInfo::Timezone.get(timezone)
|
tz = TZInfo::Timezone.get(timezone)
|
||||||
difference = Time.now.to_i - tz.now.to_i
|
difference = Time.now.to_i - tz.now.to_i
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue