diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-12-23 02:28:56 -0800 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-12-23 02:28:56 -0800 |
commit | 60fc4f4b1ab37fbfe9021f3fa1395d66a4424ed2 (patch) | |
tree | 515c4b9c8286ae363f77722c91acb878151dc386 /inc/3rdparty/libraries/html5/Parser.php | |
parent | cbfd5a1019f47fadefd8490dae9f039ae894298d (diff) | |
parent | da5fc42f615eeb45a702604970f94967507fb432 (diff) | |
download | wallabag-60fc4f4b1ab37fbfe9021f3fa1395d66a4424ed2.tar.gz wallabag-60fc4f4b1ab37fbfe9021f3fa1395d66a4424ed2.tar.zst wallabag-60fc4f4b1ab37fbfe9021f3fa1395d66a4424ed2.zip |
Merge pull request #363 from inthepoche/dev1.3.0
poche 1.3.0
Diffstat (limited to 'inc/3rdparty/libraries/html5/Parser.php')
-rw-r--r-- | inc/3rdparty/libraries/html5/Parser.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/inc/3rdparty/libraries/html5/Parser.php b/inc/3rdparty/libraries/html5/Parser.php new file mode 100644 index 00000000..5f9ca560 --- /dev/null +++ b/inc/3rdparty/libraries/html5/Parser.php | |||
@@ -0,0 +1,36 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once dirname(__FILE__) . '/Data.php'; | ||
4 | require_once dirname(__FILE__) . '/InputStream.php'; | ||
5 | require_once dirname(__FILE__) . '/TreeBuilder.php'; | ||
6 | require_once dirname(__FILE__) . '/Tokenizer.php'; | ||
7 | |||
8 | /** | ||
9 | * Outwards facing interface for HTML5. | ||
10 | */ | ||
11 | class HTML5_Parser | ||
12 | { | ||
13 | /** | ||
14 | * Parses a full HTML document. | ||
15 | * @param $text HTML text to parse | ||
16 | * @param $builder Custom builder implementation | ||
17 | * @return Parsed HTML as DOMDocument | ||
18 | */ | ||
19 | static public function parse($text, $builder = null) { | ||
20 | $tokenizer = new HTML5_Tokenizer($text, $builder); | ||
21 | $tokenizer->parse(); | ||
22 | return $tokenizer->save(); | ||
23 | } | ||
24 | /** | ||
25 | * Parses an HTML fragment. | ||
26 | * @param $text HTML text to parse | ||
27 | * @param $context String name of context element to pretend parsing is in. | ||
28 | * @param $builder Custom builder implementation | ||
29 | * @return Parsed HTML as DOMDocument | ||
30 | */ | ||
31 | static public function parseFragment($text, $context = null, $builder = null) { | ||
32 | $tokenizer = new HTML5_Tokenizer($text, $builder); | ||
33 | $tokenizer->parseFragment($context); | ||
34 | return $tokenizer->save(); | ||
35 | } | ||
36 | } | ||