Skip to content

Commit 73565f2

Browse files
committed
The tokenise object is now in a separate project and so composer is now required.
Rewired all code to use the tokenise object from the new namespace. Updated minify.md to reflect API changes. Updated readme.md to add installation instructions and link to the online minifier. Updated tag::html() to improve how attributes are encoded, now only & and < plus the quote specified as the quote style is encoded. Expanded the functionality of the minimal setting in tag::html() to switch to single quotes when there are double quotes in the attribute value to make the encoded output smaller. Updated tests.
1 parent e0b7c8c commit 73565f2

File tree

16 files changed

+126
-141
lines changed

16 files changed

+126
-141
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v2
11+
- uses: php-actions/composer@v5
1112

1213
- name: PHPUnit Tests
1314
uses: php-actions/phpunit@v2
1415
with:
1516
php_version: 7.4
1617
php_extensions: mbstring xdebug
17-
bootstrap: src/autoload.php
18+
bootstrap: vendor/autoload.php
1819
args: --coverage-text --coverage-clover=coverage.xml tests
1920
env:
2021
XDEBUG_MODE: coverage

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
{
88
"name": "Will Earp",
99
"email": "will@hexydec.com",
10-
"homepage": "https://github.com/hexydec/htmldoc"
10+
"homepage": "https://github.com/hexydec"
1111
}
1212
],
13-
"minimum-stability": "beta",
13+
"minimum-stability": "stable",
1414
"require": {
15+
"php": ">=7.3",
16+
"hexydec/tokenise": "@dev",
1517
"hexydec/cssdoc": "@dev",
1618
"hexydec/jslite": "@dev"
1719
},

composer.lock

Lines changed: 52 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/minify.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@ An optional array contains a list of configuration parameters to configure the m
3939
<td><code>true</code></td>
4040
</tr>
4141
<tr>
42-
<td rowspan="2"><code>comments</code></td>
43-
<td rowspan="2">Array</td>
44-
<td colspan="2">Remove comments, set to false to preserve comments</td>
42+
<td rowspan="3"><code>comments</code></td>
43+
<td rowspan="3">Array</td>
44+
<td colspan="2">Options for removing comments</td>
4545
<td><code>Array()</code></td>
4646
</tr>
47+
<tr>
48+
<td><code>comments</code></td>
49+
<td>Whether to remove comments</td>
50+
<td><code>true</code></td>
51+
</tr>
4752
<tr>
4853
<td><code>ie</code></td>
4954
<td>Whether to preserve Internet Explorer specific comments</td>
@@ -76,8 +81,8 @@ An optional array contains a list of configuration parameters to configure the m
7681
<td><code>true</code></td>
7782
</tr>
7883
<tr>
79-
<td rowspan="8"><code>attributes</code></td>
80-
<td rowspan="8">Array</td>
84+
<td rowspan="9"><code>attributes</code></td>
85+
<td rowspan="9">Array</td>
8186
<td colspan="2">Minify attributes</td>
8287
<td><code>Array()</code></td>
8388
</tr>

docs/how-to-use.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ if ($doc->load($html)) {
9898

9999
The `minify()` method can also accept an array of minification options to change what is minified and what is not, this can be useful for example for minification of HTML for emails.
100100

101-
To see all the available options [see the API documentation](api/minify.md).
101+
To see all the available options [API documentation for the `minify()` method](api/minify.md).
102102

103103
## Outputting Documents
104104

readme.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ if ($doc->load($html) {
3434
}
3535
```
3636

37+
You can test out the minifier online at [https://hexydec.com/htmldoc/](https://hexydec.com/htmldoc/), or run the supplied index.php file after installation.
38+
3739
To extract data from an HTML document:
3840

3941
```php
@@ -56,6 +58,18 @@ if ($doc->open($url) {
5658

5759
```
5860

61+
## Installation
62+
63+
The easiest way to get up and running is to use composer:
64+
65+
```
66+
$ composer install
67+
```
68+
69+
HTMLdoc requires [\hexydec\token\tokenise](https://github.com/hexydec/tokenise) to run, which you can install manually if not using composer. Optionally you can also install [CSSdoc](https://github.com/hexydec/cssdoc) and [JSlite](https://github.com/hexydec/jslite) to perform inline CSS and Javascript minification respectively.
70+
71+
All these dependencies will be installed through composer.
72+
5973
## Documentation
6074

6175
- [How it works](docs/how-it-works.md)

src/htmldoc/htmldoc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
declare(strict_types = 1);
33
namespace hexydec\html;
4+
use \hexydec\tokens\tokenise;
45

56
class htmldoc extends config implements \ArrayAccess, \Iterator {
67

src/htmldoc/tokenise.php

Lines changed: 0 additions & 112 deletions
This file was deleted.

src/htmldoc/tokens/comment.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
declare(strict_types = 1);
33
namespace hexydec\html;
4+
use \hexydec\tokens\tokenise;
45

56
class comment implements token {
67

src/htmldoc/tokens/doctype.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
declare(strict_types = 1);
33
namespace hexydec\html;
4+
use \hexydec\tokens\tokenise;
45

56
class doctype implements token {
67

0 commit comments

Comments
 (0)