Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: phacility/phabricator
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: rivigo-labs/phabricator
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
Loading
Showing with 1,247 additions and 12 deletions.
  1. +101 −0 externals/html2text/README.md
  2. +21 −0 externals/html2text/convert.php
  3. +16 −0 externals/html2text/html2text.php
  4. +505 −0 externals/html2text/src/Html2Text.php
  5. +14 −0 externals/html2text/src/Html2TextException.php
  6. +2 −2 scripts/install/update_phabricator.sh
  7. +9 −1 scripts/mail/mail_handler.php
  8. +8 −0 src/__phutil_library_map__.php
  9. +1 −1 src/applications/config/option/PhabricatorSecurityConfigOptions.php
  10. +2 −1 src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php
  11. +0 −1 src/applications/diffusion/worker/DiffusionUpdateObjectAfterCommitWorker.php
  12. +10 −1 src/applications/files/engine/PhabricatorFileStorageEngine.php
  13. +7 −1 src/applications/files/engine/PhabricatorLocalDiskFileStorageEngine.php
  14. +14 −0 src/applications/maniphest/config/ManiphestCategoriesConfigType.php
  15. +14 −0 src/applications/maniphest/config/ManiphestEscalationConfigType.php
  16. +82 −0 src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
  17. +114 −0 src/applications/maniphest/constants/ManiphestTaskCategory.php
  18. +113 −0 src/applications/maniphest/constants/ManiphestTaskEscalation.php
  19. +60 −1 src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php
  20. +0 −1 src/applications/passphrase/controller/PassphraseCredentialRevealController.php
  21. +1 −1 src/applications/passphrase/controller/PassphraseCredentialViewController.php
  22. +6 −0 src/applications/passphrase/xaction/PassphraseCredentialLookedAtTransaction.php
  23. +12 −0 src/applications/project/controller/PhabricatorProjectBoardImportController.php
  24. +67 −0 src/extensions/ManiphestCategoryCustomField.php
  25. +67 −0 src/extensions/ManiphestEscalatedToCustomField.php
  26. +1 −1 src/infrastructure/diff/engine/PhabricatorInlineCommentAdjustmentEngine.php
101 changes: 101 additions & 0 deletions externals/html2text/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
html2text [![Build Status](https://travis-ci.org/soundasleep/html2text.svg?branch=master)](https://travis-ci.org/soundasleep/html2text) [![Total Downloads](https://poser.pugx.org/soundasleep/html2text/downloads.png)](https://packagist.org/packages/soundasleep/html2text)
=========

html2text is a very simple script that uses DOM methods to convert HTML into a format similar to what would be
rendered by a browser - perfect for places where you need a quick text representation. For example:

```html
<html>
<title>Ignored Title</title>
<body>
<h1>Hello, World!</h1>

<p>This is some e-mail content.
Even though it has whitespace and newlines, the e-mail converter
will handle it correctly.

<p>Even mismatched tags.</p>

<div>A div</div>
<div>Another div</div>
<div>A div<div>within a div</div></div>

<a href="http://foo.com">A link</a>

</body>
</html>
```

Will be converted into:

```text
Hello, World!
This is some e-mail content. Even though it has whitespace and newlines, the e-mail converter will handle it correctly.
Even mismatched tags.
A div
Another div
A div
within a div
[A link](http://foo.com)
```

See the [original blog post](http://journals.jevon.org/users/jevon-phd/entry/19818) or the related [StackOverflow answer](http://stackoverflow.com/a/2564472/39531).

## Installing

You can use [Composer](http://getcomposer.org/) to add the [package](https://packagist.org/packages/soundasleep/html2text) to your project:

```json
{
"require": {
"soundasleep/html2text": "~1.1"
}
}
```

And then use it quite simply:

```php
$text = \Soundasleep\Html2Text::convert($html);
```

You can also include the supplied `html2text.php` and use `$text = convert_html_to_text($html);` instead.

### Options

| Option | Default | Description |
|--------|---------|-------------|
| **ignore_errors** | `false` | Set to `true` to ignore any XML parsing errors. |
| **drop_links** | `false` | Set to `true` to not render links as `[http://foo.com](My Link)`, but rather just `My Link`. |

Pass along options as a second argument to `convert`, for example:

```php
$options = array(
'ignore_errors' => true,
// other options go here
);
$text = \Soundasleep\Html2Text::convert($html, $options);
```

## Tests

Some very basic tests are provided in the `tests/` directory. Run them with `composer install && vendor/bin/phpunit`.

## Troubleshooting

### Class 'DOMDocument' not found

You need to [install the PHP XML extension](https://github.com/soundasleep/html2text/issues/55) for your PHP version. e.g. `apt-get install php7.1-xml`

## License

`html2text` is [licensed under MIT](LICENSE.md), making it suitable for both Eclipse and GPL projects.

## Other versions

Also see [html2text_ruby](https://github.com/soundasleep/html2text_ruby), a Ruby implementation.
21 changes: 21 additions & 0 deletions externals/html2text/convert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* This file allows you to convert through the command line.
* Usage:
* php -f convert.php [input file]
*/

if (count($argv) < 2) {
throw new \InvalidArgumentException("Expected: php -f convert.php [input file]");
}

if (!file_exists($argv[1])) {
throw new \InvalidArgumentException("'" . $argv[1] . "' does not exist");
}

$input = file_get_contents($argv[1]);

require_once(__DIR__ . "/src/Html2Text.php");
require_once(__DIR__ . "/src/Html2TextException.php");

echo \Soundasleep\Html2Text::convert($input);
16 changes: 16 additions & 0 deletions externals/html2text/html2text.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* This file is available if you still want to use functions rather than
* autoloading classes.
*/

require_once(__DIR__ . "/src/Html2Text.php");
require_once(__DIR__ . "/src/Html2TextException.php");

function convert_html_to_text($html, $ignore_error = false) {
return Soundasleep\Html2Text::convert($html, $ignore_error);
}

function fix_newlines($text) {
return Soundasleep\Html2Text::fixNewlines($text);
}
Loading