lib/email_reply_parser.rb
# Returns +true+ if the current block in the current fragment has
# a multiline quote header, +false+ otherwise.
#
# The quote header we're looking for is mainly generated by Outlook
# clients. It's considered a quote header if the first 4 folded lines
# have one of the following forms:
#
# label: some text
#  *label:* some text
#
# where a line like this:
#
# label: some text
#   possibly indented text that belongs to the previous line
#
# is folded into:
#
# label: some text possibly indented text that belongs to the previous line
#
# and where label is a value from +QUOTE_HEADER_LABELS+ that appears
# only once in the first 4 lines and where each group of a label
# is represented at most once.
Returns +true+ if the current block in the current fragment has
a multiline quote header, +false+ otherwise.

The quote header we're looking for is mainly generated by Outlook
clients. It's considered a quote header if the first 4 folded lines
have one of the following forms.

some text
label:* some text



some text
possibly indented text that belongs to the previous line



some text possibly indented text that belongs to the previous line

and where label is a value from +QUOTE_HEADER_LABELS+ that appears
only once in the first 4 lines and where each group of a label
is represented at most once.
Returns + true + if the current block in the current fragment has a multiline quote header + false + otherwise . The quote header we ' re looking for is mainly generated by Outlook clients . It ' s considered a quote header if the first 4 folded lines have one of the following forms . some text label : * some text some text possibly indented text that belongs to the previous line some text possibly indented text that belongs to the previous line and where label is a value from + QUOTE_HEADER_LABELS + that appears only once in the first 4 lines and where each group of a label is represented at most once .
def multiline_quote_header_in_fragment?
      folding = false
      label_groups = []
      @fragment.current_block.split("\n").each do |line|
        if line =~ /\A\s*\*?([^:]+):(\s|\*)/
          label = QUOTE_HEADER_LABELS[$1.downcase]
          if label
            return false if label_groups.include?(label)
            return true if label_groups.length == 3
            label_groups << label
            folding = true
          elsif !folding
            return false
          end
        elsif !folding
          return false
        else
          folding = true
        end
      end
      return false
    end
def multiline_quote_header_in_fragment? folding = false label_groups = [ ] @fragment . current_block . split ( "\n" ) . each do | line | if line =~ / \A \s * \* ?([^:]+):( \s | \* ) / label = QUOTE_HEADER_LABELS [ $1 . downcase ] if label return false if label_groups . include? ( label ) return true if label_groups . length == 3 label_groups << label folding = true elsif ! folding return false end elsif ! folding return false else folding = true end end return false end
Returns +true+ if the current block in the current fragment has
a multiline quote header, +false+ otherwise.
Returns + true + if the current block in the current fragment has a multiline quote header + false + otherwise .