You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removed CSSdoc as it is now a separate project, added to composer dependencies.
Updated how custom tags are handled, they can now be configured through a separate config, and built in handlers are supplied for script and style tags.
Elements with white-space: pre; are now handled differently, you can now specify minifier options for specific elements, and defaults are provided to make <pre>, <textarea>, and <code> keep their whitespace.
Can now specify output options per element, this enables SVG's to be output as XML compliant.
Added a test for SVG output.
Copy file name to clipboardExpand all lines: docs/api/construct.md
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,6 @@ The options set into the object are setup for general use, but can be configured
18
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
19
|`singleton`| HTML elements that are singletons |`['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']`|
20
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']`|
23
21
24
22
#### `attributes`
25
23
@@ -31,6 +29,26 @@ The options set into the object are setup for general use, but can be configured
31
29
|`urls`| Attributes that contain urls |`['href', 'src', 'action', 'poster']`|
32
30
|`urlskip`| Skips compressing URLs if tag => attribute => value matches | <code>[<br> 'link' => [<br> 'rel' => ['stylesheet', 'icon', 'shortcut icon', 'apple-touch-icon-precomposed', 'apple-touch-icon', 'preload', 'prefetch', 'author', 'help']<br> ]<br>]</code> |
33
31
32
+
#### `custom`
33
+
34
+
This option enables you to specify custom handlers for specific tags. By default there are built in handlers for `style` and `script` tags, currently CSS is minified using [hexydec\\css\\cssdoc](https://github.com/hexydec/cssdoc) if you install the module using composer.
35
+
36
+
There is currently no built-in minifier for Javascript, although an external minifier can be specified in the custom tag options:
|`class`| The name of the handler class (Should implement \hexydec\html\token) |
41
+
|`config`| An array of custom configuration to be passed to the handler class |
42
+
43
+
Note that the built in `style` and `script` handlers both specify `minifier` in the `config` array, here you can specify a callback for a custom minifier with the following pattern:
Copy file name to clipboardExpand all lines: docs/api/html.md
+14-3Lines changed: 14 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,10 +21,10 @@ if ($doc->load($html)) {
21
21
</thead>
22
22
<tbody>
23
23
<tr>
24
-
<td rowspan="5"><code>$options</code></td>
25
-
<td rowspan="5">Array</td>
24
+
<td rowspan="6"><code>$options</code></td>
25
+
<td rowspan="6">Array</td>
26
26
<td colspan="2">An array of output options, the input is merged with `htmldoc::$config['output']`. <em>Note that for most scenarios, specifying this argument is not required</em></td>
27
-
<td><code>Array()</code</td>
27
+
<td><code>[]</code></td>
28
28
</tr>
29
29
<tr>
30
30
<td><code>quotestyle</code></td>
@@ -46,6 +46,17 @@ if ($doc->load($html)) {
46
46
<td>A boolean specifying whether to render XML compliant output. Setting this to <code>true</code> automatically sets <code>quotestyle = "double"</code>, <code>singletonclose = "/>"</code>, and <code>closetag = true</code></td>
47
47
<td><code>false</code></td>
48
48
</tr>
49
+
<tr>
50
+
<td><code>elements</code></td>
51
+
<td>An array specifying output options for specific tags</td>
An HTML and CSS parser, primarily designed for minifying HTML documents, it also enables the document structure to be queried allowing attribute and textnode values to be extracted.
11
+
An HTML parser, primarily designed for minifying HTML documents, it also enables the document structure to be queried allowing attribute and textnode values to be extracted.
12
12
13
13
Both parsers are designed around a tokeniser to make the document processing more reliable than regex based minifiers, which are a bit blunt and can be problematic if they match patterns in the wrong places.
14
14
15
+
The software is also capable of processing and minifying SVG documents.
0 commit comments