summaryrefslogtreecommitdiff
path: root/src/HTML5.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/HTML5.php')
-rw-r--r--src/HTML5.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/HTML5.php b/src/HTML5.php
index d43539f..7009136 100644
--- a/src/HTML5.php
+++ b/src/HTML5.php
@@ -58,7 +58,7 @@ class HTML5 {
}
/**
- * Parse an HTML string.
+ * Parse a HTML Document from a string.
*
* Take a string of HTML 5 (or earlier) and parse it into a
* DOMDocument.
@@ -85,6 +85,21 @@ class HTML5 {
}
/**
+ * Parse a HTML fragment from a string.
+ *
+ * @param string $string
+ * The html5 fragment as a string.
+ *
+ * @return \DOMDocumentFragment
+ * A DOM fragment. The DOM is part of libxml, which is included with
+ * almost all distributions of PHP.
+ */
+ public static function loadHTMLFragment($string) {
+ $input = new StringInputStream($string);
+ return self::parseFragment($input);
+ }
+
+ /**
* Save a DOM into a given file as HTML5.
*
* @param mixed $dom