class Octodown::Renderer::HTML
Attributes
filepath[R]
logger[R]
options[R]
rendered_markdown[R]
Public Class Methods
new(rendered_markdown, options = {})
click to toggle source
# File lib/octodown/renderer/html.rb, line 14 def initialize(rendered_markdown, options = {}) @logger = options[:logger] @rendered_markdown = rendered_markdown @options = options @filepath = File.join parent_dir, 'template', 'octodown.html.erb' end
Public Instance Methods
content()
click to toggle source
# File lib/octodown/renderer/html.rb, line 21 def content template_text = File.read filepath erb_template = ERB.new template_text erb_template.result binding end
highlight_stylesheet()
click to toggle source
# File lib/octodown/renderer/html.rb, line 36 def highlight_stylesheet inject_html_node_with_file_content assets_dir('highlight.css'), :style end
host()
click to toggle source
# File lib/octodown/renderer/html.rb, line 40 def host "ws://localhost:#{options[:port]}".dump end
present()
click to toggle source
# File lib/octodown/renderer/html.rb, line 44 def present if options[:no_open] logger.warn('--no-open argument was used so no browser will be opened') else Launchy.open PersistentTempfile.create(content, :html).path end end
stylesheet()
click to toggle source
# File lib/octodown/renderer/html.rb, line 31 def stylesheet stylesheet = "#{options[:style]}.css" inject_html_node_with_file_content assets_dir(stylesheet), :style end
title()
click to toggle source
# File lib/octodown/renderer/html.rb, line 27 def title 'Octodown Preview' end
Private Instance Methods
assets_dir(*args)
click to toggle source
# File lib/octodown/renderer/html.rb, line 58 def assets_dir(*args) File.join Octodown.root, 'assets', args end
inject_html_node_with_file_content(name, tag)
click to toggle source
# File lib/octodown/renderer/html.rb, line 54 def inject_html_node_with_file_content(name, tag) "<#{tag}>#{File.read name}</#{tag}>" end
parent_dir()
click to toggle source
# File lib/octodown/renderer/html.rb, line 62 def parent_dir current_file = File.dirname __FILE__ File.expand_path '..', current_file end