File: excerpt.rb

package info (click to toggle)
ruby-jekyll-asciidoc 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,536 kB
  • sloc: ruby: 1,802; sh: 36; makefile: 6
file content (49 lines) | stat: -rw-r--r-- 1,552 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module Jekyll
  module AsciiDoc
    class Excerpt < ::Jekyll::Excerpt
      if Jekyll3_0
        def_delegators :@doc, :destination, :url
      else
        def_delegators :@doc, :destination
      end

      def initialize primary_doc, excerpt_content
        excerpt_doc = primary_doc.dup
        excerpt_doc.content = excerpt_content
        excerpt_doc.extend NoLiquid unless primary_doc.data['liquid']
        super excerpt_doc
      end

      def extract_excerpt content
        # NOTE excerpt_doctype has already been resolved from either the page attribute or front matter variable
        if (doctype = (excerpt_data = data)['excerpt_doctype'] ||
            (inherited = doc.site.config['asciidoc']['excerpt_doctype']))
          excerpt_data['doctype'] = doctype
          excerpt_data['excerpt_doctype'] = doc.data['excerpt_doctype'] = doctype if inherited
        end
        content
      end

      def output
        unless defined? @output
          renderer = ::Jekyll::Renderer.new doc.site, self, site.site_payload
          @output = renderer.run
          trigger_hooks :post_render
        end
        @output
      end

      def render_with_liquid?
        !(NoLiquid === doc)
      end

      # NOTE Jekyll 3.0 incorrectly maps to_liquid to primary doc
      alias to_liquid data if Jekyll3_0

      def trigger_hooks hook_name, *args
        #::Jekyll::Hooks.trigger collection.label.to_sym, hook_name, self, *args if collection
        ::Jekyll::Hooks.trigger :documents, hook_name, self, *args
      end
    end
  end
end