Sha256: 3f20faf29b4b7c3fd5deaa6edfb2931adc7f4cf19c6f157582747b504fe2f726

Contents?: true

Size: 661 Bytes

Versions: 25

Compression:

Stored size: 661 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  module ParsingHelpers
    # Yield each chunk outside of "...", '...'
    def outside_of_strings(markup)
      scanner = StringScanner.new(markup)

      while scanner.scan(/.*?("|')/m)
        chunk_start = scanner.pre_match.size
        yield scanner.matched[0..-2], chunk_start
        quote = scanner.matched[-1] == "'" ? "'" : "\""
        # Skip to the end of the string
        # Check for empty string first, since follow regexp uses lookahead
        scanner.skip(/#{quote}/) || scanner.skip_until(/[^\\]#{quote}/)
      end

      yield scanner.rest, scanner.charpos if scanner.rest?
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
theme-check-1.15.0 lib/theme_check/parsing_helpers.rb
theme-check-1.14.0 lib/theme_check/parsing_helpers.rb
theme-check-1.13.0 lib/theme_check/parsing_helpers.rb
theme-check-1.12.1 lib/theme_check/parsing_helpers.rb
theme-check-1.12.0 lib/theme_check/parsing_helpers.rb
theme-check-1.11.0 lib/theme_check/parsing_helpers.rb
theme-check-1.10.3 lib/theme_check/parsing_helpers.rb
theme-check-1.10.2 lib/theme_check/parsing_helpers.rb
theme-check-1.10.1 lib/theme_check/parsing_helpers.rb
theme-check-1.10.0 lib/theme_check/parsing_helpers.rb
theme-check-1.9.2 lib/theme_check/parsing_helpers.rb
theme-check-1.9.1 lib/theme_check/parsing_helpers.rb
theme-check-1.9.0 lib/theme_check/parsing_helpers.rb
theme-check-1.8.0 lib/theme_check/parsing_helpers.rb
theme-check-1.7.2 lib/theme_check/parsing_helpers.rb
theme-check-1.7.1 lib/theme_check/parsing_helpers.rb
theme-check-1.7.0 lib/theme_check/parsing_helpers.rb
theme-check-1.6.2 lib/theme_check/parsing_helpers.rb
theme-check-1.6.1 lib/theme_check/parsing_helpers.rb
theme-check-1.6.0 lib/theme_check/parsing_helpers.rb