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