Sha256: 16b0535de9b4d3bdc0f212525bc4c59fe942a812ef885ff7e94fbd17b0e503b2

Contents?: true

Size: 884 Bytes

Versions: 34

Compression:

Stored size: 884 Bytes

Contents

require 'set'

# Hamlit::Parsers::Whitespace cares about "whitespace removal",
# which is achieved by '<' or '>' after html tag.
module Hamlit
  module Parsers
    module Whitespace
      def parse_whitespace_removal(scanner)
        if scanner.match?(/</)
          inner_removal = parse_inner_removal(scanner)
          parse_outer_removal(scanner)
        else
          parse_outer_removal(scanner)
          inner_removal = parse_inner_removal(scanner)
        end
        inner_removal
      end

      private

      def reset_outer_removal
        @outer_removal = Set.new
      end

      def parse_inner_removal(scanner)
        scanner.scan(/</)
      end

      def parse_outer_removal(scanner)
        if scanner.scan(/>/)
          @outer_removal.add(@current_indent)
        else
          @outer_removal.delete(@current_indent)
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
hamlit-1.4.7 lib/hamlit/parsers/whitespace.rb
hamlit-1.4.6 lib/hamlit/parsers/whitespace.rb
hamlit-1.4.5 lib/hamlit/parsers/whitespace.rb
hamlit-1.4.3 lib/hamlit/parsers/whitespace.rb
hamlit-1.4.2 lib/hamlit/parsers/whitespace.rb
hamlit-1.4.1 lib/hamlit/parsers/whitespace.rb
hamlit-1.3.2 lib/hamlit/parsers/whitespace.rb
hamlit-1.3.1 lib/hamlit/parsers/whitespace.rb
hamlit-1.3.0 lib/hamlit/parsers/whitespace.rb
hamlit-1.2.1 lib/hamlit/parsers/whitespace.rb
hamlit-1.2.0 lib/hamlit/parsers/whitespace.rb
hamlit-1.1.1 lib/hamlit/parsers/whitespace.rb
hamlit-1.1.0 lib/hamlit/parsers/whitespace.rb
hamlit-1.0.0 lib/hamlit/parsers/whitespace.rb
hamlit-0.6.2 lib/hamlit/parsers/whitespace.rb
hamlit-0.6.1 lib/hamlit/parsers/whitespace.rb
hamlit-0.6.0 lib/hamlit/parsers/whitespace.rb
hamlit-0.5.3 lib/hamlit/parsers/whitespace.rb
hamlit-0.5.2 lib/hamlit/parsers/whitespace.rb
hamlit-0.5.1 lib/hamlit/parsers/whitespace.rb