lib/kss/comment_parser.rb
# Normalizes the comment block to ignore any consistent preceding
# whitespace. Consistent means the same amount of whitespace on every line
# of the comment block. Also strips any whitespace at the start and end of
# the whole block.
#
# Returns a String of normalized text.
Normalizes the comment block to ignore any consistent preceding
whitespace. Consistent means the same amount of whitespace on every line
of the comment block. Also strips any whitespace at the start and end of
the whole block.

Returns a String of normalized text.
Normalizes the comment block to ignore any consistent preceding whitespace . Consistent means the same amount of whitespace on every line of the comment block . Also strips any whitespace at the start and end of the whole block . Returns a String of normalized text .
def normalize(text_block)
      return text_block if @options[:preserve_whitespace]
      text_block = text_block.gsub(/^(\s*\*+)/, '')
      indent_size = nil
      unindented = text_block.split("\n").collect do |line|
        preceding_whitespace = line.scan(/^\s*/)[0].to_s.size
        indent_size = preceding_whitespace if indent_size.nil?
        if line == ""
          ""
        elsif indent_size <= preceding_whitespace && indent_size > 0
          line.slice(indent_size, line.length - 1)
        else
          line
        end
      end.join("\n")
      unindented.strip
    end
def normalize ( text_block ) return text_block if @options [ :preserve_whitespace ] text_block = text_block . gsub ( / ^( \s * \* +) / , '' ) indent_size = nil unindented = text_block . split ( "\n" ) . collect do | line | preceding_whitespace = line . scan ( / ^ \s * / ) [ 0 ] . to_s . size indent_size = preceding_whitespace if indent_size . nil? if line == "" "" elsif indent_size <= preceding_whitespace && indent_size > 0 line . slice ( indent_size , line . length - 1 ) else line end end . join ( "\n" ) unindented . strip end
Normalizes the comment block to ignore any consistent preceding
whitespace.
Normalizes the comment block to ignore any consistent preceding whitespace .
# Strip out any preceding [whitespace]* that occur on every line. Not # the smartest, but I wonder if I care. # Strip consistent indenting by measuring first line's whitespace
text_block
<not_specific>