Class: Trifle::Docs::Harvester::Markdown::Conveyor

Inherits:
Conveyor
  • Object
show all
Defined in:
lib/trifle/docs/harvester/markdown.rb

Instance Attribute Summary

Attributes inherited from Conveyor

#file, #namespace, #url

Instance Method Summary collapse

Methods inherited from Conveyor

#data, #initialize

Constructor Details

This class inherits a constructor from Trifle::Docs::Harvester::Conveyor

Instance Method Details

#contentObject



29
30
31
32
33
34
35
36
# File 'lib/trifle/docs/harvester/markdown.rb', line 29

def content
  @content ||= Redcarpet::Markdown.new(
    Render.new(with_toc_data: true),
    fenced_code_blocks: true,
    disable_indented_code_blocks: true,
    footnotes: true
  ).render(data.sub(/^---(.*?)---(\s*)/m, ''))
end

#metaObject



38
39
40
41
42
43
44
# File 'lib/trifle/docs/harvester/markdown.rb', line 38

def meta
  @meta ||= (YAML.safe_load(data[/^---(.*?)---(\s*)/m].to_s) || {}).merge(
    'url' => "/#{[namespace, url].compact.join('/')}",
    'breadcrumbs' => url.split('/'),
    'toc' => toc
  )
end

#tocObject



46
47
48
49
50
# File 'lib/trifle/docs/harvester/markdown.rb', line 46

def toc
  @toc ||= Redcarpet::Markdown.new(
    Redcarpet::Render::HTML_TOC
  ).render(data.sub(/^---(.*?)---(\s*)/m, ''))
end