Class: Seo::HtmlPrettyPrinter
- Inherits:
-
BaseService
- Object
- BaseService
- Seo::HtmlPrettyPrinter
- Defined in:
- app/services/seo/html_pretty_printer.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#process(html_fragment) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/seo/html_pretty_printer.rb', line 6 def process(html_fragment) logger.tagged('Seo::HtmlPrettyPrinter') do errors = [] begin # Use HtmlBeautifier to format the HTML pretty_html = HtmlBeautifier.beautify(html_fragment, indent: ' ') Result.new( html_out: pretty_html, errors: errors ) rescue StandardError => e errors << { error: e. } logger.error "Error pretty printing HTML: #{e.}" Result.new( html_out: html_fragment, # Return original HTML if there's an error errors: errors ) end end end |