Class: Mado::Markdown

Inherits:
Object
  • Object
show all
Defined in:
lib/mado/markdown.rb

Defined Under Namespace

Classes: HTML

Class Method Summary collapse

Class Method Details

.convert_markdown(path) ⇒ Object



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
# File 'lib/mado/markdown.rb', line 8

def convert_markdown(path)
  renderer_options = {
    filter_html: true,
    with_toc_data: true
  }
  convert_options = {
    autolink: true,
    fenced_code_blocks: true,
    lax_spacing: true,
    no_intra_emphasis: true,
    strikethrough: true,
    superscript: true,
    tables: true
  }
  pipeline_context = {
    asset_root: ""
  }
  pipeline = ::HTML::Pipeline.new [
    ::HTML::Pipeline::EmojiFilter,
    TaskList::Filter
  ]

  renderer = HTML.new(renderer_options)
  html = Redcarpet::Markdown.new(renderer, convert_options).render(open(path).read)
  pipeline.call(html, pipeline_context)[:output].to_s
end

.emoji_path(file_path) ⇒ Object



35
36
37
# File 'lib/mado/markdown.rb', line 35

def emoji_path(file_path)
  File.join(Emoji.images_path, "emoji", file_path)
end