Sha256: 484503969456d484ba895bd180546666f3194999722f3121bdefaac173924293

Contents?: true

Size: 459 Bytes

Versions: 9

Compression:

Stored size: 459 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(/.*?("|')/)
        yield scanner.matched[0..-2]
        # Skip to the end of the string
        scanner.skip_until(scanner.matched[-1] == "'" ? /[^\\]'/ : /[^\\]"/)
      end

      yield scanner.rest if scanner.rest?
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
theme-check-0.10.2 lib/theme_check/parsing_helpers.rb
theme-check-0.10.1 lib/theme_check/parsing_helpers.rb
theme-check-0.10.0 lib/theme_check/parsing_helpers.rb
theme-check-0.9.1 lib/theme_check/parsing_helpers.rb
theme-check-0.9.0 lib/theme_check/parsing_helpers.rb
theme-check-0.8.3 lib/theme_check/parsing_helpers.rb
theme-check-0.8.2 lib/theme_check/parsing_helpers.rb
theme-check-0.8.1 lib/theme_check/parsing_helpers.rb
theme-check-0.8.0 lib/theme_check/parsing_helpers.rb