Module: Plezi::Base::RenderMarkDown

Extended by:
HasStore
Defined in:
lib/plezi/render/markdown.rb

Defined Under Namespace

Classes: NewPageLinksMDRenderer

Constant Summary collapse

MD_EXTENSIONS =

Extensions

{ with_toc_data: true, strikethrough: true, autolink: true, fenced_code_blocks: true, no_intra_emphasis: true, tables: true, footnotes: true, underline: true, highlight: true }.freeze
MD_RENDERER =

create a single gloabl renderer for all markdown files.

Redcarpet::Markdown.new NewPageLinksMDRenderer.new(MD_EXTENSIONS.dup), MD_EXTENSIONS.dup
MD_RENDERER_TOC =

create a single gloabl renderer for all markdown TOC.

Redcarpet::Markdown.new Redcarpet::Render::HTML_TOC.new(MD_EXTENSIONS.dup), MD_EXTENSIONS.dup

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasStore

get, store

Class Method Details

.call(filename, _context) ⇒ Object

renders the markdown file, if exists



36
37
38
39
# File 'lib/plezi/render/markdown.rb', line 36

def call(filename, _context)
   return unless File.exist?(filename)
   load_engine(filename)
end

Instance Method Details

#load_engine(filename) ⇒ Object

loads the rendered cache



43
44
45
46
47
48
# File 'lib/plezi/render/markdown.rb', line 43

def load_engine(filename)
   engine = self[filename]
   return engine if engine
   data = IO.read filename
   self[filename] = "<div class='toc'>#{::Plezi::Base::RenderMarkDown::MD_RENDERER_TOC.render(data)}</div>\n#{::Plezi::Base::RenderMarkDown::MD_RENDERER.render(data)}"
end