-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b96a55
commit f25f8c6
Showing
6 changed files
with
65 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: ci | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
phpunit: | ||
runs-on: "ubuntu-20.04" | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-version: | ||
- "7.4" | ||
- "8.0" | ||
- "8.1" | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: "Install PHP ${{ matrix.php-version }}" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "${{ matrix.php-version }}" | ||
coverage: "pcov" | ||
|
||
- name: "Install dependencies with Composer" | ||
uses: "ramsey/composer-install@v1" | ||
|
||
- name: "Run PHPUnit" | ||
run: "vendor/bin/simple-phpunit --coverage-text" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
vendor/ | ||
composer.lock | ||
.phpunit.result.cache |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
EmailReplyParser | ||
================ | ||
# EmailReplyParser | ||
|
||
[![Build | ||
Status](https://secure.travis-ci.org/willdurand/EmailReplyParser.png)](http://travis-ci.org/willdurand/EmailReplyParser) | ||
[![GitHub Actions](https://github.com/willdurand/EmailReplyParser/workflows/ci/badge.svg)](https://github.com/willdurand/EmailReplyParser/actions?query=workflow%3A%22ci%22+branch%3Amaster) | ||
[![Total | ||
Downloads](https://poser.pugx.org/willdurand/email-reply-parser/downloads.png)](https://packagist.org/packages/willdurand/email-reply-parser) | ||
[![Latest Stable | ||
|
@@ -12,23 +10,20 @@ Version](https://poser.pugx.org/willdurand/email-reply-parser/v/stable.png)](htt | |
based on GitHub's [email_reply_parser](http://github.com/github/email_reply_parser) | ||
library written in Ruby. | ||
|
||
|
||
Installation | ||
------------ | ||
## Installation | ||
|
||
The recommended way to install EmailReplyParser is through | ||
[Composer](http://getcomposer.org/): | ||
|
||
``` shell | ||
```shell | ||
composer require willdurand/email-reply-parser | ||
``` | ||
|
||
Usage | ||
----- | ||
## Usage | ||
|
||
Instantiate an `EmailParser` object and parse your email: | ||
|
||
``` php | ||
```php | ||
<?php | ||
|
||
use EmailReplyParser\Parser\EmailParser; | ||
|
@@ -39,14 +34,14 @@ $email = (new EmailParser())->parse($emailContent); | |
You get an `Email` object that contains a set of `Fragment` objects. The `Email` | ||
class exposes two methods: | ||
|
||
* `getFragments()`: returns all fragments; | ||
* `getVisibleText()`: returns a string which represents the content considered | ||
- `getFragments()`: returns all fragments; | ||
- `getVisibleText()`: returns a string which represents the content considered | ||
as "visible". | ||
|
||
The `Fragment` represents a part of the full email content, and has the | ||
following API: | ||
|
||
``` php | ||
```php | ||
<?php | ||
|
||
$fragment = current($email->getFragments()); | ||
|
@@ -65,15 +60,13 @@ $fragment->isEmpty(); | |
Alternatively, you can rely on the `EmailReplyParser` to either parse an email | ||
or get its visible content in a single line of code: | ||
|
||
``` php | ||
```php | ||
$email = \EmailReplyParser\EmailReplyParser::read($emailContent); | ||
|
||
$visibleText = \EmailReplyParser\EmailReplyParser::parseReply($emailContent); | ||
``` | ||
|
||
|
||
Known Issues | ||
------------ | ||
## Known Issues | ||
|
||
### Quoted Headers | ||
|
||
|
@@ -84,23 +77,23 @@ Quoted headers aren't picked up if there's an extra line break: | |
> blah | ||
|
||
Also, they're not picked up if the email client breaks it up into | ||
multiple lines. GMail breaks up any lines over 80 characters for you. | ||
multiple lines. GMail breaks up any lines over 80 characters for you. | ||
|
||
On <date>, <author> | ||
wrote: | ||
> blah | ||
|
||
The above `On ....wrote:` can be cleaned up with the following regex: | ||
|
||
``` php | ||
```php | ||
$fragment_without_date_author = preg_replace( | ||
'/\nOn(.*?)wrote:(.*?)$/si', | ||
'', | ||
$fragment->getContent() | ||
'/\nOn(.*?)wrote:(.*?)$/si', | ||
"", | ||
$fragment->getContent() | ||
); | ||
``` | ||
|
||
Note though that we're search for "on" and "wrote". Therefore, it won't work | ||
Note though that we're search for "on" and "wrote". Therefore, it won't work | ||
with other languages. | ||
|
||
Possible solution: Remove "[email protected]" lines... | ||
|
@@ -127,8 +120,6 @@ Not everyone follows this convention: | |
* Note: blah blah blah * | ||
**********************DISCLAIMER*********************************** | ||
|
||
|
||
|
||
### Strange Quoting | ||
|
||
Apparently, prefixing lines with `>` isn't universal either: | ||
|
@@ -143,34 +134,26 @@ Apparently, prefixing lines with `>` isn't universal either: | |
Sent: Monday, March 14, 2011 6:16 PM | ||
To: Rick | ||
|
||
|
||
Unit Tests | ||
---------- | ||
## Unit Tests | ||
|
||
Setup the test suite using Composer: | ||
|
||
$ composer install | ||
|
||
Run it using PHPUnit: | ||
|
||
$ ./vendor/bin/phpunit | ||
|
||
$ ./vendor/bin/simple-phpunit | ||
|
||
Contributing | ||
------------ | ||
## Contributing | ||
|
||
See CONTRIBUTING file. | ||
|
||
## Credits | ||
|
||
Credits | ||
------- | ||
|
||
* GitHub | ||
* William Durand | ||
|
||
- GitHub | ||
- William Durand | ||
|
||
License | ||
------- | ||
## License | ||
|
||
EmailReplyParser is released under the MIT License. See the bundled LICENSE | ||
file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters