Sha256: 99d2a8b540a9a98c56311015d2c13637213da763e49354b4fc43da9a4a2e7b5d
Contents?: true
Size: 667 Bytes
Versions: 25
Compression:
Stored size: 667 Bytes
Contents
# frozen_string_literal: true module PlatformosCheck 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