Sha256: 31a209cef55d01a1cf95655e949c6af619f9e67286162711a965d0f491ba7b2e
Contents?: true
Size: 786 Bytes
Versions: 2
Compression:
Stored size: 786 Bytes
Contents
require_relative '../../html_to_haml' module HtmlToHaml::Html class IndentationTracker def initialize(indentation_amount:) @indentation_level = 0 @inside_self_closing_tag = false @indentation_amount = indentation_amount end def start_html_tag @indentation_level += @indentation_amount unless @inside_self_closing_tag @inside_self_closing_tag = false end def start_self_closing_tag @inside_self_closing_tag = true end def close_html_tag @indentation_level -= @indentation_amount if @indentation_level < 0 raise ParseError, 'The html is malformed and is attempting to close an html tag that was never started' end end def indentation " " * @indentation_level end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
html-to-haml-0.0.6 | lib/html_to_haml/tools/html/indentation_tracker.rb |
html-to-haml-0.0.5 | lib/html_to_haml/tools/html/indentation_tracker.rb |