lib/jekyll/assets/utils.rb in jekyll-assets-3.0.2 vs lib/jekyll/assets/utils.rb in jekyll-assets-3.0.3

- old
+ new

@@ -3,10 +3,32 @@ # Encoding: utf-8 module Jekyll module Assets module Utils + def self.html_fragment(*a) + Nokogiri::HTML.fragment(*a) do |c| + c.options = Nokogiri::XML::ParseOptions::NONET | \ + Nokogiri::XML::ParseOptions::NOENT + end + end + + # -- + def self.html(*a) + Nokogiri::HTML.parse(*a) do |c| + c.options = Nokogiri::XML::ParseOptions::NONET | \ + Nokogiri::XML::ParseOptions::NOENT + end + end + + # -- + def self.xml(*a) + Nokogiri::XML.parse(*a) do |c| + c.options = Nokogiri::XML::ParseOptions::NONET + end + end + def raw_precompiles asset_config[:raw_precompile].each_with_object([]) do |v, a| if v.is_a?(Hash) dst, src = in_dest_dir.join(v[:dst]).tap(&:mkdir_p), v[:src] glob_paths(src).each do |sv| @@ -301,48 +323,9 @@ if block_given? yield end rescue ExecJS::RuntimeUnavailable nil - end - - # -- - # @param [Jekyll::Site] site - # @param [Hash<Symbol,Object>] payload - # Try to replicate and run hooks the Jekyll would normally run. - # rubocop:disable Metrics/LineLength - # @return nil - # -- - def run_liquid_hooks(payload, site) - Hook.trigger(:liquid, :pre_render) { |h| h.call(payload, site) } - post, page, doc = get_liquid_obj(payload, site) - - # I would assume most people set in :pre_render logically? - Jekyll::Hooks.trigger(:posts, :pre_render, post, payload) if post - Jekyll::Hooks.trigger(:documents, :pre_render, post || doc, payload) if post || doc - Jekyll::Hooks.trigger(:pages, :pre_render, page, payload) if page - end - - # -- - # @param [Jekyll::Site] site - # @param [Hash<Symbol,Object>] payload - # Discovers the Jekyll object, corresponding to the type. - # @note this allows us to trigger hooks that Jekyll would trigger. - # @return [Jekyll::Document, Jekyll::Page] - # rubocop:disable Layout/ExtraSpacing - # -- - def get_liquid_obj(payload, site) - path = payload["path"] - - post = site.posts.docs.find { |v| v.relative_path == path } - docs = site. documents.find { |v| v.relative_path == path } unless post - page = site. pages.find { |v| v.relative_path == path } unless docs - - [ - post, - page, - docs, - ] end end end end