class Markun::Core
Constants
- HTML_TEMPLATE
- MARKUN_FILE
- MARKUN_TEMPLATE
Public Instance Methods
execute()
click to toggle source
Private Instance Methods
convert_markdown_to_html(have_menu)
click to toggle source
# File lib/markun_core.rb, line 55 def convert_markdown_to_html(have_menu) Dir.glob('**/*.md').each do |file| md = File.read(file) contents = Kramdown::Document.new(md.force_encoding('utf-8')).to_html menu = get_menu(file, have_menu) html = get_html_template(File.basename(file, '.md'), contents, menu) html_file_name = file.gsub('.md', '.html') File.open(html_file_name, 'w:utf-8') { |f|f.puts html.encode('utf-8') } end end
get_each_urls()
click to toggle source
# File lib/markun_core.rb, line 93 def get_each_urls Dir.glob('./*.md').map { |f|File.absolute_path(f) } end
get_html_template(title, contents, menu)
click to toggle source
# File lib/markun_core.rb, line 73 def get_html_template(title, contents, menu) erb = ERB.new(HTML_TEMPLATE) erb.result(binding) end
get_urls(urls)
click to toggle source
# File lib/markun_core.rb, line 83 def get_urls(urls) urls += get_each_urls Dir.glob('*/') do |d| Dir.chdir(d) urls = get_urls(urls) Dir.chdir('../') end urls end
read_dsl()
click to toggle source
# File lib/markun_core.rb, line 51 def read_dsl File.open(MARKUN_FILE) { |f|f.read } end