Sha256: 885a5a65cbd99bceca7c4b2903a4bb5b3415ffd97d5857b834455509a4d8e311
Contents?: true
Size: 496 Bytes
Versions: 3
Compression:
Stored size: 496 Bytes
Contents
module JekyllGithubSample module TextUtils INDEN_REGEX = /^\s+/ def remove_common_indentation(lines) leading_spaces = [] lines.each do |line| next if line.length == 1 if indentation_match = line.match(INDEN_REGEX) leading_spaces << indentation_match[0].length else leading_spaces << 0 end end lines.collect do |line| line.length == 1 ? line : line[leading_spaces.min..-1] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems