Class: Octodown::Renderer::HTML
- Inherits:
-
Object
- Object
- Octodown::Renderer::HTML
- Includes:
- Renderable, Support
- Defined in:
- lib/octodown/renderer/html.rb
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rendered_markdown ⇒ Object
readonly
Returns the value of attribute rendered_markdown.
Instance Method Summary collapse
- #content ⇒ Object
- #highlight_stylesheet ⇒ Object
- #host ⇒ Object
-
#initialize(rendered_markdown, options = {}) ⇒ HTML
constructor
A new instance of HTML.
- #present ⇒ Object
- #stylesheet ⇒ Object
- #title ⇒ Object
Methods included from Renderable
Constructor Details
#initialize(rendered_markdown, options = {}) ⇒ HTML
Returns a new instance of HTML.
12 13 14 15 16 |
# File 'lib/octodown/renderer/html.rb', line 12 def initialize(rendered_markdown, = {}) @rendered_markdown = rendered_markdown @options = @filepath = File.join parent_dir, 'template', 'octodown.html.erb' end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
10 11 12 |
# File 'lib/octodown/renderer/html.rb', line 10 def filepath @filepath end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/octodown/renderer/html.rb', line 10 def @options end |
#rendered_markdown ⇒ Object (readonly)
Returns the value of attribute rendered_markdown.
10 11 12 |
# File 'lib/octodown/renderer/html.rb', line 10 def rendered_markdown @rendered_markdown end |
Instance Method Details
#content ⇒ Object
18 19 20 21 22 |
# File 'lib/octodown/renderer/html.rb', line 18 def content template_text = File.read filepath erb_template = ERB.new template_text erb_template.result binding end |
#highlight_stylesheet ⇒ Object
33 34 35 |
# File 'lib/octodown/renderer/html.rb', line 33 def highlight_stylesheet inject_html_node_with_file_content assets_dir('highlight.css'), :style end |
#host ⇒ Object
37 38 39 |
# File 'lib/octodown/renderer/html.rb', line 37 def host "ws://localhost:#{[:port]}".dump end |
#present ⇒ Object
41 42 43 |
# File 'lib/octodown/renderer/html.rb', line 41 def present Launchy.open PersistentTempfile.create(content, :html).path end |
#stylesheet ⇒ Object
28 29 30 31 |
# File 'lib/octodown/renderer/html.rb', line 28 def stylesheet stylesheet = "#{[:style]}.css" inject_html_node_with_file_content assets_dir(stylesheet), :style end |
#title ⇒ Object
24 25 26 |
# File 'lib/octodown/renderer/html.rb', line 24 def title 'Octodown Preview' end |