Class: MarkdownExtension::Summary

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown_extension/summary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Summary

Returns a new instance of Summary.



7
8
9
10
11
12
13
14
15
# File 'lib/markdown_extension/summary.rb', line 7

def initialize(config)
    @config = config
    file = config.src+"/summary.md"
    if File.exist?(file)
        @markdown = File.read(file)
    else
        @markdown = ""
    end
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/markdown_extension/summary.rb', line 6

def config
  @config
end

#markdownObject

Returns the value of attribute markdown.



6
7
8
# File 'lib/markdown_extension/summary.rb', line 6

def markdown
  @markdown
end

Instance Method Details

#htmlObject



26
27
28
29
# File 'lib/markdown_extension/summary.rb', line 26

def html
    pre_processing()
    return Kramdown::Document.new(@markdown, input: 'GFM').to_html            
end

#pre_processingObject



17
18
19
20
21
22
23
24
# File 'lib/markdown_extension/summary.rb', line 17

def pre_processing
    if @config.preprocessing["backlinks"]
        @markdown = @markdown.gsub(/\[\[(.*)\]\]/) do |s| 
            s = s[2..-3]
            "[#{s}](#{s}.html)"
        end
    end
end