Method: MaRuKu::Strings#strip_indent
- Defined in:
- lib/maruku/string_utils.rb
#strip_indent(s, n) ⇒ String
Removes indentation from the beginning of ‘s`, up to at most `n` spaces. Tabs are counted as TAB_SIZE spaces.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/maruku/string_utils.rb', line 103 def strip_indent(s, n) while n > 0 case s[0, 1] when ' ' n -= 1 when "\t" n -= TAB_SIZE else break end s = s[1..-1] end MDLine.new(s) end |