Module: JekyllGithubSample::TextUtils
- Included in:
- CodeTag
- Defined in:
- lib/jekyll_github_sample/text_utils.rb
Constant Summary collapse
- INDEN_REGEX =
/^\s+/
Instance Method Summary collapse
Instance Method Details
#remove_common_indentation(lines) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jekyll_github_sample/text_utils.rb', line 6 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 |