class AutoPilot::MarkdownConverter

Constants

DEFAULT_BLOG_FOLDER

Attributes

answer[R]
doc[R]
h1_tag[R]
question[R]

Public Class Methods

new(doc) click to toggle source
# File lib/auto_pilot/markdown_converter.rb, line 11
def initialize(doc)
  @h1_tag   = to_markdown doc.title_html
  @question = to_markdown doc.question_html
  @answer   = to_markdown doc.answer_html
  make_folder_if_doesnt_exist
  write_file_to_disk(AutoPilot.configuration.folder, :md)
end

Private Instance Methods

delimiter() click to toggle source
# File lib/auto_pilot/markdown_converter.rb, line 35
def delimiter
  '--------------------------------------- '
end
front_matter() click to toggle source
# File lib/auto_pilot/markdown_converter.rb, line 39
    def front_matter
      <<-BLOCK.unindent
      ---
      layout: post
      title: "#{h1_tag.strip}"
      description: ""
      category:
      tags: []
      ---
      BLOCK
    end
md_template() click to toggle source
# File lib/auto_pilot/markdown_converter.rb, line 25
    def md_template
      @markdown ||= <<-BLOCK.unindent
      #{front_matter unless AutoPilot.configuration.disable_front_matter}
      #{h1_tag}
      #{question}
      #{delimiter}
      #{answer}
      BLOCK
    end
to_markdown(html) click to toggle source
# File lib/auto_pilot/markdown_converter.rb, line 21
def to_markdown(html)
  ReverseMarkdown.convert html
end