1- EmailReplyParser
2- ================
1+ # EmailReplyParser
32
4- [ ![ Build
5- Status] ( https://secure.travis-ci.org/willdurand/EmailReplyParser.png )] ( http://travis-ci.org/willdurand/EmailReplyParser )
3+ [ ![ GitHub Actions] ( https://github.com/willdurand/EmailReplyParser/workflows/ci/badge.svg )] ( https://github.com/willdurand/EmailReplyParser/actions?query=workflow%3A%22ci%22+branch%3Amaster )
64[ ![ Total
75Downloads] ( https://poser.pugx.org/willdurand/email-reply-parser/downloads.png )] ( https://packagist.org/packages/willdurand/email-reply-parser )
86[ ](htt
1210based on GitHub's [ email_reply_parser] ( http://github.com/github/email_reply_parser )
1311library written in Ruby.
1412
15-
16- Installation
17- ------------
13+ ## Installation
1814
1915The recommended way to install EmailReplyParser is through
2016[ Composer] ( http://getcomposer.org/ ) :
2117
22- ``` shell
18+ ``` shell
2319composer require willdurand/email-reply-parser
2420```
2521
26- Usage
27- -----
22+ ## Usage
2823
2924Instantiate an ` EmailParser ` object and parse your email:
3025
31- ``` php
26+ ``` php
3227<?php
3328
3429use EmailReplyParser\Parser\EmailParser;
@@ -39,14 +34,14 @@ $email = (new EmailParser())->parse($emailContent);
3934You get an ` Email ` object that contains a set of ` Fragment ` objects. The ` Email `
4035class exposes two methods:
4136
42- * ` getFragments() ` : returns all fragments;
43- * ` getVisibleText() ` : returns a string which represents the content considered
37+ - ` getFragments() ` : returns all fragments;
38+ - ` getVisibleText() ` : returns a string which represents the content considered
4439 as "visible".
4540
4641The ` Fragment ` represents a part of the full email content, and has the
4742following API:
4843
49- ``` php
44+ ``` php
5045<?php
5146
5247$fragment = current($email->getFragments());
@@ -65,15 +60,13 @@ $fragment->isEmpty();
6560Alternatively, you can rely on the ` EmailReplyParser ` to either parse an email
6661or get its visible content in a single line of code:
6762
68- ``` php
63+ ``` php
6964$email = \EmailReplyParser\EmailReplyParser::read($emailContent);
7065
7166$visibleText = \EmailReplyParser\EmailReplyParser::parseReply($emailContent);
7267```
7368
74-
75- Known Issues
76- ------------
69+ ## Known Issues
7770
7871### Quoted Headers
7972
@@ -84,23 +77,23 @@ Quoted headers aren't picked up if there's an extra line break:
8477 > blah
8578
8679Also, they're not picked up if the email client breaks it up into
87- multiple lines. GMail breaks up any lines over 80 characters for you.
80+ multiple lines. GMail breaks up any lines over 80 characters for you.
8881
8982 On <date>, <author>
9083 wrote:
9184 > blah
9285
9386The above ` On ....wrote: ` can be cleaned up with the following regex:
9487
95- ``` php
88+ ``` php
9689$fragment_without_date_author = preg_replace(
97- '/\nOn(.*?)wrote:(.*?)$/si',
98- '' ,
99- $fragment->getContent()
90+ '/\nOn(.*?)wrote:(.*?)$/si',
91+ "" ,
92+ $fragment->getContent()
10093);
10194```
10295
103- Note though that we're search for "on" and "wrote". Therefore, it won't work
96+ Note though that we're search for "on" and "wrote". Therefore, it won't work
10497with other languages.
10598
10699Possible solution: Remove "
[email protected] " lines...
@@ -127,8 +120,6 @@ Not everyone follows this convention:
127120 * Note: blah blah blah *
128121 **********************DISCLAIMER***********************************
129122
130-
131-
132123### Strange Quoting
133124
134125Apparently, prefixing lines with ` > ` isn't universal either:
@@ -143,34 +134,26 @@ Apparently, prefixing lines with `>` isn't universal either:
143134 Sent: Monday, March 14, 2011 6:16 PM
144135 To: Rick
145136
146-
147- Unit Tests
148- ----------
137+ ## Unit Tests
149138
150139Setup the test suite using Composer:
151140
152141 $ composer install
153142
154143Run it using PHPUnit:
155144
156- $ ./vendor/bin/phpunit
157-
145+ $ ./vendor/bin/simple-phpunit
158146
159- Contributing
160- ------------
147+ ## Contributing
161148
162149See CONTRIBUTING file.
163150
151+ ## Credits
164152
165- Credits
166- -------
167-
168- * GitHub
169- * William Durand
170-
153+ - GitHub
154+ - William Durand
171155
172- License
173- -------
156+ ## License
174157
175158EmailReplyParser is released under the MIT License. See the bundled LICENSE
176159file for details.
0 commit comments