Skip to content

Commit 211b3fa

Browse files
committed
Undo Prettier markdown formatting
1 parent 1927d92 commit 211b3fa

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

README.md

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
# PHP Html Parser
1+
PHP Html Parser
2+
==========================
23

34
[![Build Status](https://travis-ci.org/paquettg/php-html-parser.png)](https://travis-ci.org/paquettg/php-html-parser)
45
[![Coverage Status](https://coveralls.io/repos/paquettg/php-html-parser/badge.png)](https://coveralls.io/r/paquettg/php-html-parser)
56
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/paquettg/php-html-parser/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/paquettg/php-html-parser/?branch=master)
67

78
PHPHtmlParser is a simple, flexible, html parser which allows you to select tags using any css selector, like jQuery. The goal is to assist in the development of tools which require a quick, easy way to scrap html, whether it's valid or not!
89

9-
## Install
10+
Install
11+
-------
1012

1113
Install the latest version using composer.
1214

@@ -16,7 +18,8 @@ $ composer require paquettg/php-html-parser
1618

1719
This package can be found on [packagist](https://packagist.org/packages/paquettg/php-html-parser) and is best loaded using [composer](http://getcomposer.org/). We support php 7.2, 7.3, and 7.4.
1820

19-
## Basic Usage
21+
Basic Usage
22+
-----
2023

2124
You can find many examples of how to use the DOM parser and any of its parts (which you will most likely never touch) in the tests directory. The tests are done using PHPUnit and are very small, a few lines each, and are a great place to start. Given that, I'll still be showing a few examples of how the package should be used. The following example is a very simplistic usage of the package.
2225

@@ -33,13 +36,15 @@ echo $a->text; // "click here"
3336

3437
The above will output "click here". Simple, no? There are many ways to get the same result from the DOM, such as `$dom->getElementsbyTag('a')[0]` or `$dom->find('a', 0)`, which can all be found in the tests or in the code itself.
3538

36-
## Support PHP Html Parser Financially
39+
Support PHP Html Parser Financially
40+
--------------
3741

3842
Get supported Monolog and help fund the project with the [Tidelift Subscription](https://tidelift.com/subscription/pkg/packagist-paquettg-php-html-parser?utm_source=packagist-paquettg-php-html-parser&utm_medium=referral&utm_campaign=enterprise).
3943

4044
Tidelift delivers commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.
4145

42-
## Loading Files
46+
Loading Files
47+
------------------
4348

4449
You may also seamlessly load a file into the DOM instead of a string, which is much more convenient and is how I expect most developers will be loading the HTML. The following example is taken from our test and uses the "big.html" file found there.
4550

@@ -57,7 +62,7 @@ foreach ($contents as $content)
5762
{
5863
// get the class attr
5964
$class = $content->getAttribute('class');
60-
65+
6166
// do something with the html
6267
$html = $content->innerHtml;
6368

@@ -69,9 +74,10 @@ foreach ($contents as $content)
6974

7075
This example loads the html from big.html, a real page found online, and gets all the content-border classes to process. It also shows a few things you can do with a node but it is not an exhaustive list of the methods that a node has available.
7176

72-
## Loading URLs
77+
Loading URLs
78+
----------------
7379

74-
Loading a URL is very similar to the way you would load the HTML from a file.
80+
Loading a URL is very similar to the way you would load the HTML from a file.
7581

7682
```php
7783
// Assuming you installed from Composer:
@@ -102,7 +108,8 @@ $html = $dom->outerHtml;
102108

103109
As long as the client object implements the interface properly, it will use that object to get the content of the url.
104110

105-
## Loading Strings
111+
Loading Strings
112+
---------------
106113

107114
Loading a string directly is also easily done.
108115

@@ -116,7 +123,8 @@ $dom->loadStr('<html>String</html>');
116123
$html = $dom->outerHtml;
117124
```
118125

119-
## Options
126+
Options
127+
-------
120128

121129
You can also set parsing option that will effect the behavior of the parsing engine. You can set a global option array using the `setOptions` method in the `Dom` object or a instance specific option by adding it to the `load` method as an extra (optional) parameter.
122130

@@ -133,7 +141,7 @@ $dom->setOptions(
133141
->setStrict(true)
134142
);
135143

136-
$dom->loadFromUrl('http://google.com',
144+
$dom->loadFromUrl('http://google.com',
137145
(new Options())->setWhitespaceTextNode(false) // only applies to this load.
138146
);
139147

@@ -190,7 +198,8 @@ This option contains an array of all self closing tags. These tags must be self
190198

191199
This option contains an array of all tags that can not be self closing. The list starts off as empty but you can add elements as you wish.
192200

193-
## Static Facade
201+
Static Facade
202+
-------------
194203

195204
You can also mount a static facade for the Dom object.
196205

@@ -204,7 +213,8 @@ $objects = Dom::find('.content-border');
204213

205214
The above php block does the same find and load as the first example but it is done using the static facade, which supports all public methods found in the Dom object.
206215

207-
## Modifying The Dom
216+
Modifying The Dom
217+
-----------------
208218

209219
You can always modify the dom that was created from any loading method. To change the attribute of any node you can just call the `setAttribute` method.
210220

0 commit comments

Comments
 (0)