Class: DelimiterMatcher
- Inherits:
-
Object
- Object
- DelimiterMatcher
- Defined in:
- lib/email_reply_trimmer/delimiter_matcher.rb
Constant Summary collapse
- DELIMITER_CHARACTERS =
"-_,=+~#*ᐧ—"- DELIMITER_REGEX =
/^[[:blank:]]*[#{Regexp.escape(DELIMITER_CHARACTERS)}]+[[:blank:]]*$/- BULLET_MARKER_REGEX =
A single "-" or "" on its own line (ignoring surrounding blanks) is the way many mail clients render a plain-text bullet list item, not a reply or signature separator. Real separators built from these characters use at least two of them ("--", "**", "-----"), so excluding the lone case avoids discarding bullet-list content while leaving genuine separators (and every other delimiter character) untouched.
/\A[[:blank:]]*[-*][[:blank:]]*\z/
Class Method Summary collapse
Class Method Details
.match?(line) ⇒ Boolean
15 16 17 18 19 |
# File 'lib/email_reply_trimmer/delimiter_matcher.rb', line 15 def self.match?(line) return false if BULLET_MARKER_REGEX.match?(line) line =~ DELIMITER_REGEX end |