Class: RSpecDocumentation::Formatters::Html
- Inherits:
-
Object
- Object
- RSpecDocumentation::Formatters::Html
- Defined in:
- lib/rspec_documentation/formatters/html.rb
Overview
Beautifies HTML received from a ‘subject`, renders the raw subject to be inserted directly into the output document.
Constant Summary collapse
- DOCTYPE_TAG =
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ' \ '"http://www.w3.org/TR/REC-html40/loose.dtd">'
Instance Method Summary collapse
-
#initialize(subject:) ⇒ Html
constructor
A new instance of Html.
- #prettified_output ⇒ Object
- #render_raw? ⇒ Boolean
- #rendered_output ⇒ Object
Constructor Details
#initialize(subject:) ⇒ Html
Returns a new instance of Html.
10 11 12 |
# File 'lib/rspec_documentation/formatters/html.rb', line 10 def initialize(subject:) @subject = subject end |
Instance Method Details
#prettified_output ⇒ Object
14 15 16 17 18 |
# File 'lib/rspec_documentation/formatters/html.rb', line 14 def prettified_output formatter = Rouge::Formatters::HTML.new lexer = Rouge::Lexers::HTML.new formatter.format(lexer.lex(HtmlBeautifier.beautify(subject))) end |
#render_raw? ⇒ Boolean
24 25 26 |
# File 'lib/rspec_documentation/formatters/html.rb', line 24 def render_raw? true end |
#rendered_output ⇒ Object
20 21 22 |
# File 'lib/rspec_documentation/formatters/html.rb', line 20 def rendered_output subject&.to_s&.sub(DOCTYPE_TAG, '') end |