Skip to content

Commit f203533

Browse files
committed
Updated documentation to correct grammar.
Renamed 'urlsmatch' option to 'urlskip'. Changed instances of Array() to [].
1 parent 281ad5e commit f203533

19 files changed

+95
-94
lines changed

docs/api/attr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# attr()
22

3-
Retrieves the value of the requested attribute from the first item in an HTMLDoc collection.
3+
Retrieves the value of the requested attribute from the first item in an HTMLdoc collection.
44

55
```php
66
$doc = new \hexydec\html\htmldoc();

docs/api/construct.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,22 @@ The options set into the object are setup for general use, but can be configured
1515

1616
| option | Description | Defaults |
1717
|---------------|---------------------------------------------------|-------------------------------|
18-
| `inline` | HTML elements that are considered inline | `Array('b', 'u', 'big', 'i', 'small', 'ttspan', 'em', 'a', 'strong', 'sub', 'sup', 'abbr', 'acronym', 'cite', 'code', 'dfn', 'em', 'kbd', 'strong', 'samp', 'var', 'span')` |
19-
| `singleton` | HTML elements that are singletons | `Array('area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr')` |
20-
| `closeoptional` | HTML elements that don't have to be closed | `Array('head', 'body', 'p', 'dt', 'dd', 'li', 'option', 'thead', 'th', 'tbody', 'tr', 'td', 'tfoot', 'colgroup')` |
21-
| `pre` | HTML elements that contain pre-formatted content | `Array('textarea', 'pre', 'code')` |
22-
| `plugins` | HTML elements that have a custom handler class | `Array('script', 'style')` |
18+
| `inline` | HTML elements that are considered inline | `['b', 'u', 'big', 'i', 'small', 'ttspan', 'em', 'a', 'strong', 'sub', 'sup', 'abbr', 'acronym', 'cite', 'code', 'dfn', 'em', 'kbd', 'strong', 'samp', 'var', 'span']` |
19+
| `singleton` | HTML elements that are singletons | `['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']` |
20+
| `closeoptional` | HTML elements that don't have to be closed | `['head', 'body', 'p', 'dt', 'dd', 'li', 'option', 'thead', 'th', 'tbody', 'tr', 'td', 'tfoot', 'colgroup']` |
21+
| `pre` | HTML elements that contain pre-formatted content | `['textarea', 'pre', 'code']` |
22+
| `plugins` | HTML elements that have a custom handler class | `['script', 'style']` |
2323

2424
#### `attributes`
2525

2626
| option | Description | Defaults |
2727
|---------------|---------------------------------------------------|-------------------------------|
28-
| `boolean` | HTML attributes that are boolean values | `Array('allowfullscreen', 'allowpaymentrequest', 'async', 'autofocus', 'autoplay', 'checked', 'contenteditable', 'controls', 'default', 'defer', 'disabled', 'formnovalidate', 'hidden', 'indeterminate', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'readonly', 'required', 'reversed', 'scoped', 'selected', 'typemustmatch')` |
29-
| `default` | Default attributes that can be removed | <code>Array(<br>&nbsp; &nbsp; 'style' => Array('type' => 'text/css'),<br>&nbsp; &nbsp; 'script' => Array('type' => 'text/javascript', 'language' => true),<br>&nbsp; &nbsp; 'form' => Array('method' => 'get'),<br>&nbsp; &nbsp; 'input' => Array('type' => 'text')<br>)</code> |
30-
| `empty` | Attributes to remove if empty | `Array('id', 'class', 'style', 'title')` |
31-
| `urls` | Attributes that contain urls | `Array('href', 'src', 'action', 'poster')` |
28+
| `boolean` | HTML attributes that are boolean values | `['allowfullscreen', 'allowpaymentrequest', 'async', 'autofocus', 'autoplay', 'checked', 'contenteditable', 'controls', 'default', 'defer', 'disabled', 'formnovalidate', 'hidden', 'indeterminate', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'readonly', 'required', 'reversed', 'scoped', 'selected', 'typemustmatch']` |
29+
| `default` | Default attributes that can be removed | <code>[<br>&nbsp; &nbsp; 'style' => ['type' => 'text/css'],<br>&nbsp; &nbsp; 'script' => ['type' => 'text/javascript', 'language' => true],<br>&nbsp; &nbsp; 'form' => ['method' => 'get'],<br>&nbsp; &nbsp; 'input' => ['type' => 'text']<br>]</code> |
30+
| `empty` | Attributes to remove if empty | `['id', 'class', 'style', 'title']` |
31+
| `urls` | Attributes that contain urls | `['href', 'src', 'action', 'poster']` |
32+
| `urlskip` | Skips compressing URLs if tag => attribute => value matches | <code>[<br>&nbsp; &nbsp; 'link' => [<br>&nbsp; &nbsp; &nbsp; &nbsp; 'rel' => ['stylesheet', 'icon', 'shortcut icon', 'apple-touch-icon-precomposed', 'apple-touch-icon', 'preload', 'prefetch', 'author', 'help']<br>&nbsp; &nbsp; ]<br>]</code> |
3233

3334
## Returns
3435

35-
A new HTMLDoc object.
36+
A new HTMLdoc object.

docs/api/eq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# eq()
22

3-
Builds a new HTMLDoc collection containing only the node at the index requested.
3+
Builds a new HTMLdoc collection containing only the node at the index requested.
44

55
```php
66
$doc = new \hexydec\html\htmldoc();
@@ -17,4 +17,4 @@ An integer indicating the zero based index of the element to return. A minus val
1717

1818
## Returns
1919

20-
An HTMLDoc collection containing the element at the index requested, or an empty HTMLDoc collection if the index is out of range.
20+
An HTMLdoc collection containing the element at the index requested, or an empty HTMLdoc collection if the index is out of range.

docs/api/find.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ $found = $doc->find('form a.button, form label.button');
4242
```
4343
## Returns
4444

45-
An HTMLDoc object containing the matched nodes, or an empty HTMLDoc collection if no matches were found.
45+
An HTMLdoc object containing the matched nodes, or an empty HTMLdoc collection if no matches were found.

docs/api/first.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# first()
22

3-
Returns a new HTMLDoc collection containing the first element in the collection.
3+
Returns a new HTMLdoc collection containing the first element in the collection.
44

55
## Returns
66

7-
An HTMLDoc collection containing the element the first element in the collection, or an empty HTMLDoc collection if the collection is empty.
7+
An HTMLdoc collection containing the element the first element in the collection, or an empty HTMLdoc collection if the collection is empty.

docs/api/last.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# last()
22

3-
Returns a new HTMLDoc collection containing the last element in the collection.
3+
Returns a new HTMLdoc collection containing the last element in the collection.
44

55
## Returns
66

7-
An HTMLDoc collection containing the element the last element in the collection, or an empty HTMLDoc collection if the collection is empty.
7+
An HTMLdoc collection containing the element the last element in the collection, or an empty HTMLdoc collection if the collection is empty.

docs/api/minify.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ An optional array contains a list of configuration parameters to configure the m
2929
<td>Boolean</td>
3030
<td></td>
3131
<td>Lowercase tag and attribute names</td>
32-
<td>true</td>
32+
<td><code>true</code></td>
3333
</tr>
3434
<tr>
3535
<td><code>whitespace</code></td>
3636
<td>Boolean</td>
3737
<td></td>
3838
<td>Strip whitespace from text nodes (Preserves whitespace between inline items defined in <code>htmldoc::$config['elements']['inline']</code>)</td>
39-
<td>true</td>
39+
<td><code>true</code></td>
4040
</tr>
4141
<tr>
4242
<td rowspan="2"><code>comments</code></td>
@@ -47,7 +47,7 @@ An optional array contains a list of configuration parameters to configure the m
4747
<tr>
4848
<td><code>ie</code></td>
4949
<td>Whether to preserve Internet Explorer specific comments</td>
50-
<td>true</td>
50+
<td><code>true</code></td>
5151
</tr>
5252
<tr>
5353
<td rowspan="5"><code>urls</code></td>
@@ -58,22 +58,22 @@ An optional array contains a list of configuration parameters to configure the m
5858
<tr>
5959
<td><code>scheme</code></td>
6060
<td>Remove the scheme from URLs that have the same scheme as the current document</td>
61-
<td>true</td>
61+
<td><code>true</code></td>
6262
</tr>
6363
<tr>
6464
<td><code>host</code></td>
6565
<td>Remove the host for own domain</td>
66-
<td>true</td>
66+
<td><code>true</code></td>
6767
</tr>
6868
<tr>
6969
<td><code>relative</code></td>
7070
<td>Process absolute URLs to make them relative to the current document</td>
71-
<td>true</td>
71+
<td><code>true</code></td>
7272
</tr>
7373
<tr>
7474
<td><code>parent</code></td>
7575
<td>Process relative URLs to use parent folders (<code>../</code>) where it is shorter</td>
76-
<td>true</td>
76+
<td><code>true</code></td>
7777
</tr>
7878
<tr>
7979
<td rowspan="8"><code>attributes</code></td>
@@ -84,65 +84,65 @@ An optional array contains a list of configuration parameters to configure the m
8484
<tr>
8585
<td><code>default</code></td>
8686
<td>Remove default attributes as defined in <code>htmldoc::$config['attributes']['default']</code></td>
87-
<td>true</td>
87+
<td><code>true</code></td>
8888
</tr>
8989
<tr>
9090
<td><code>empty</code></td>
9191
<td>Remove attributes with empty values, the attributes processed are defined in <code>htmldoc::$config['attributes']['empty']</code></td>
92-
<td>true</td>
92+
<td><code>true</code></td>
9393
</tr>
9494
<tr>
9595
<td><code>option</code></td>
9696
<td>Remove the <code>value</code> attribute from <code>option</code> tags where the text node has the same value</td>
97-
<td>true</td>
97+
<td><code>true</code></td>
9898
</tr>
9999
<tr>
100100
<td><code>style</code></td>
101101
<td>Remove whitespace and last semi-colon from the <code>style</code> attribute</td>
102-
<td>true</td>
102+
<td><code>true</code></td>
103103
</tr>
104104
<tr>
105105
<td><code>class</code></td>
106-
<td>Sort class names</td>
107-
<td>true</td>
106+
<td>Sort class names for better gzip compression</td>
107+
<td><code>true</code></td>
108108
</tr>
109109
<tr>
110110
<td><code>sort</code></td>
111-
<td>Sort attributes</td>
112-
<td>true</td>
111+
<td>Sort attributes for better gzip compression</td>
112+
<td><code>true</code></td>
113113
</tr>
114114
<tr>
115115
<td><code>boolean</code></td>
116116
<td>Minify boolean attributes to render only the attribute name and not the value. Boolean attributes are defined in <code>htmldoc::$config['attributes']['boolean']</code></td>
117-
<td>true</td>
117+
<td><code>true</code></td>
118118
</tr>
119119
<tr>
120120
<td><code>singleton</code></td>
121121
<td>Boolean</td>
122122
<td></td>
123123
<td>Removes spaces and slash in singleton attributes, e.g. <code>&lt;br /&gt;</code> becomes <code>&lt;br&gt;</code></td>
124-
<td>true</td>
124+
<td><code>true</code></td>
125125
</tr>
126126
<tr>
127127
<td><code>quotes</code></td>
128128
<td>Boolean</td>
129129
<td></td>
130130
<td>Removes quotes from attribute values where possible</td>
131-
<td>true</td>
131+
<td><code>true</code></td>
132132
</tr>
133133
<tr>
134134
<td><code>close</code></td>
135135
<td>Boolean</td>
136136
<td></td>
137-
<td>Removes closing tags for elements defined in `htmldoc::$config['elements']['closeoptional']` where possible</td>
138-
<td>true</td>
137+
<td>Removes closing tags for elements defined in <code>htmldoc::$config['elements']['closeoptional']</code> where possible</td>
138+
<td><code>true</code></td>
139139
</tr>
140140
<tr>
141141
<td><code>email</code></td>
142142
<td>Boolean</td>
143143
<td></td>
144144
<td>Sets the minification presets to email safe options</td>
145-
<td>false</td>
145+
<td><code>false</code></td>
146146
</tr>
147147
</tbody>
148148
</table>

docs/api/readme.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# HTMLDoc API Reference
1+
# HTMLdoc API Reference
22

3-
This document describes how to configure and use the HTMLDoc object.
3+
This document describes how to configure and use the HTMLdoc object.
44

55
| Method | Description |
66
|-----------------------------------|-------------------------------------------|
7-
| [__construct()](construct.md) | Constructs an HTMLDoc object |
7+
| [__construct()](construct.md) | Constructs an HTMLdoc object |
88
| [open()](open.md) | Open an HTML file from a URL or stream |
99
| [load()](load.md) | Load HTML from a strings |
1010
| [find()](find.md) | Find elements within the documents |
1111
| [eq()](eq.md) | Filter elements to the selected index |
1212
| [first()](first.md) | Filter elements by the first element |
1313
| [last()](last.md) | Filter elements by the last element |
1414
| [attr()](attr.md) | Retrieve the value of an attribute |
15-
| [text()](text.md) | Extract text from an HTMLDoc |
16-
| [minify()](minify.md) | Minify the HTMLDoc |
17-
| [html()](html.md) | Render the document as HTMLDoc |
15+
| [text()](text.md) | Extract text from an HTMLdoc |
16+
| [minify()](minify.md) | Minify the HTMLdoc |
17+
| [html()](html.md) | Render the document as HTMLdoc |
1818
| [save()](save.md) | Save as a file or output as a string |

docs/api/text.md

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

1212
## Returns
1313

14-
A string containing the combined contents of the text nodes in an HTMLDoc collection.
14+
A string containing the combined contents of the text nodes in an HTMLdoc collection.

docs/how-it-works.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# HTMLDoc: How it works
1+
# HTMLdoc: How it works
22

33
Under the hood, the software processes are split into a number of stages:
44

docs/how-to-use.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# HTMLDoc: How to Use
1+
# HTMLdoc: How to Use
22

3-
HTMLDoc has been designed to be as simple to use as possible, but with enough configuration options to control the output more closely.
3+
HTMLdoc has been designed to be as simple to use as possible, but with enough configuration options to control the output more closely.
44

5-
## Configuring HTMLDoc
5+
## Configuring HTMLdoc
66

77
The default configuration has been setup to give the best options for most needs. If you do need to change the configuration, the configuration options can be passed to the object upon creation:
88

99
```php
10-
$config = Array(
11-
'elements' => Array(
12-
'pre' => Array(
10+
$config = [
11+
'elements' => [
12+
'pre' => [
1313
'span' // treat spans as pre formattted
14-
)
15-
)
16-
);
14+
]
15+
]
16+
];
1717
$doc = new \hexydec\html\htmldoc($config);
1818
```
1919

@@ -24,6 +24,7 @@ To see all of the configuration options, see the [API documentation for the `__c
2424
HTML can be loaded in two ways, either from a string, or from a stream:
2525

2626
### From a String
27+
2728
```php
2829
$html = '<div>Hello World</div>'; // can be a snippet
2930
$charset = mb_internal_encoding(); // UTF-8?
@@ -35,14 +36,15 @@ if ($doc->load($html, $charset)) {
3536
```
3637

3738
### From a Stream
39+
3840
```php
3941
$url = 'https://github.com/hexydec'; // of course you want to parse this page
40-
$context = stream_context_create(Array(
41-
'http' => Array(
42+
$context = stream_context_create([
43+
'http' => [
4244
'user-agent' => 'My HTML Bot 1.0 (Mozilla Compatible)',
4345
'timeout' => 10
44-
)
45-
));
46+
]
47+
]);
4648

4749
$doc = new \hexydec\html\htmldoc();
4850
if ($doc->open($url, $context, $error)) {
@@ -56,15 +58,15 @@ For more information, see the API documentation for the [`load()` method](api/lo
5658

5759
## Finding Elements and Extracting Information
5860

59-
You can use standard CSS selectors to query an HTMLDoc object after you have loaded some HTML:
61+
You can use standard CSS selectors to query an HTMLdoc object after you have loaded some HTML:
6062

6163
```php
6264
$url = 'https://github.com/hexydec';
6365

6466
$doc = new \hexydec\html\htmldoc();
6567
if ($doc->open($url, $context, $error)) {
6668

67-
// make a new HTMLDoc containg just this node
69+
// make a new HTMLdoc containg just this node
6870
$name = $doc->find(".vcard-fullname");
6971

7072
// echo my name
@@ -84,7 +86,7 @@ For more information, [see the API documentation](api/readme.md).
8486

8587
## Minifying Documents
8688

87-
When minifying documents, HTMLDoc updates the internal representation of the document and some of the output settings. When the document is saved, the generated code will then be smaller.
89+
When minifying documents, HTMLdoc updates the internal representation of the document and some of the output settings. When the document is saved, the generated code will then be smaller.
8890

8991
```php
9092
$doc = new \hexydec\html\htmldoc();
@@ -94,13 +96,13 @@ if ($doc->load($html)) {
9496
}
9597
```
9698

97-
The `minify()` method can also accept an array of minification options to change what is minifed and what is not, this can be useful for example for minification of HTML for emails.
99+
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.
98100

99101
To see all the available options [see the API documentation](api/minify.md).
100102

101103
## Outputting Documents
102104

103-
HTML can be rendered in the following ways from your HTMLDoc object:
105+
HTML can be rendered in the following ways from your HTMLdoc object:
104106

105107
```php
106108
$doc = new \hexydec\html\htmldoc();

docs/mitigating-side-effects.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# HTMLDoc: Mitigating Side Effects of Minification
1+
# HTMLdoc: Mitigating Side Effects of Minification
22

33
Whilst all transformations performed on the input HTML will produce valid HTML, some side effects may be present as a result of the transformed code.
44

55
## CSS Side Effects
66

77
### Absolute Values in Attribute Selectors
88

9-
Selectors that reference an absolute value may no longer work after minification of an HTMLDoc document if the attribute in question is transformed into a shorter form. Consider the following HTML:
9+
Selectors that reference an absolute value may no longer work after minification of an HTMLdoc document if the attribute in question is transformed into a shorter form. Consider the following HTML:
1010

1111
```html
1212
<a href="https://github.com/hexydec">Go to my GitHub Page</a>
@@ -38,13 +38,13 @@ Depending on your specific case you may need to change any CSS that uses match v
3838

3939
### Testing attributes that may have been removed
4040

41-
Depending on the attribute you are selecting, if it is empty, the HTMLDoc minification operation may remove the attribute altogether. Consider the following HTML:
41+
Depending on the attribute you are selecting, if it is empty, the HTMLdoc minification operation may remove the attribute altogether. Consider the following HTML:
4242

4343
```html
4444
<input type="text" name="test" value="" />
4545
```
4646

47-
You may wish to have it look different depending on whether the `value` attribute is empty or target it by its `type` attribute:
47+
You may wish to apply different styles depending on whether the `value` attribute is empty or target it by its `type` attribute:
4848

4949
```css
5050
input[type=text] {
@@ -76,7 +76,7 @@ input[value]:not([value='']) {
7676

7777
### Reading Attributes
7878

79-
If your javascript code expects an attribute to exist, you may need to update your code to take into account that the attribute might not exist at all. Consider the following HTML:
79+
If your Javascript code expects an attribute to exist, you may need to update your code to take into account that the attribute might not exist at all. Consider the following HTML:
8080

8181
```html
8282
<input type="text" name="test" value="" />
@@ -120,6 +120,6 @@ if (obj instanceof HTMLElement) {
120120

121121
## Other Side-Effects
122122

123-
There may be other side-effects associated with the transformations performed by HTMLDoc, this page will be updated with more examples where appropriate.
123+
There may be other side-effects associated with the transformations performed by HTMLdoc, this page will be updated with more examples where appropriate.
124124

125125
If you discover a side-effect which you think needs documenting, please [create an issue in the tracker](https://github.com/hexydec/htmldoc/issues).

0 commit comments

Comments
 (0)