Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make ShortcodeParser use HTMLValue for HTML parsing

  • Loading branch information...
commit 53128c5d2ff44cdb958e69a2dd4a1ebb9355929a 1 parent 168f071
Hamish Friedlander hafriedlander authored sminnee committed
14 model/HTMLValue.php
View
@@ -124,6 +124,20 @@ public function __call($method, $arguments) {
}
/**
+ * Get the body element, or false if there isn't one (we haven't loaded any content
+ * or this instance is in an invalid state)
+ */
+ public function getBody() {
+ $doc = $this->getDocument();
+ if (!$doc) return false;
+
+ $body = $doc->getElementsByTagName('body');
+ if (!$body->length) return false;
+
+ return $body->item(0);
+ }
+
+ /**
* Make an xpath query against this HTML
*
* @param $query string - The xpath query string
75 parsers/ShortcodeParser.php
View
@@ -321,9 +321,8 @@ protected function replaceTagsWithText($content, $tags, $generator) {
*
* @param DOMDocument $doc
*/
- protected function replaceAttributeTagsWithContent($doc) {
- $xp = new DOMXPath($doc);
- $attributes = $xp->query('//@*[contains(.,"[")][contains(.,"]")]');
+ protected function replaceAttributeTagsWithContent($htmlvalue) {
+ $attributes = $htmlvalue->query('//@*[contains(.,"[")][contains(.,"]")]');
$parser = $this;
for($i = 0; $i < $attributes->length; $i++) {
@@ -462,7 +461,7 @@ protected function moveMarkerToCompliantHome($node, $parent, $location) {
}
/**
- * Given a node with represents a shortcode marker and some informationabout the shortcode, call the
+ * Given a node with represents a shortcode marker and some information about the shortcode, call the
* shortcode handler & replace the marker with the actual content
*
* @param DOMElement $node
@@ -488,57 +487,14 @@ protected function replaceMarkerWithContent($node, $tag) {
}
if ($content) {
- $parsed = HTML5_Parser::parseFragment($content, 'div');
- $this->insertListAfter($parsed, $node);
+ $parsed = Injector::inst()->create('HTMLValue', $content);
+ $body = $parsed->getBody();
+ if ($body) $this->insertListAfter($body->childNodes, $node);
}
$this->removeNode($node);
}
- protected function loadHTML($html) {
- require_once(THIRDPARTY_PATH.'/html5lib/HTML5/Parser.php');
-
- // Convert any errors to exceptions
- set_error_handler(
- function($no, $str){
- throw new Exception("HTML Parse Error: ".$str);
- },
- error_reporting()
- );
-
- // Use HTML5lib to parse the HTML fragment
- try {
- $bases = HTML5_Parser::parseFragment(trim($html), 'div');
- }
- catch (Exception $e) {
- $bases = null;
- }
-
- // Disable our error handler (restoring to previous value)
- restore_error_handler();
-
- return $bases;
- }
-
- protected function saveHTML($doc) {
- if (version_compare(PHP_VERSION, '5.3.6', '>=')){
- $res = '';
- foreach($doc->firstChild->childNodes as $child) $res .= $doc->saveHTML($child);
- }
- else {
- $res = preg_replace(
- array(
- '/^(.*?)<html>/is',
- '/<\/html>(.*?)$/is',
- ),
- '',
- $doc->saveHTML()
- );
- }
-
- return $res;
- }
-
/**
* Parse a string, and replace any registered shortcodes within it with the result of the mapped callback.
*
@@ -556,11 +512,10 @@ public function parse($content) {
// use a proper DOM
list($content, $tags) = $this->replaceElementTagsWithMarkers($content);
+ $htmlvalue = Injector::inst()->create('HTMLValue', $content);
+
// Now parse the result into a DOM
- $bases = $this->loadHTML($content);
-
- // If we couldn't parse the HTML, error out
- if (!$bases || !$bases->length) {
+ if (!$htmlvalue->isValid()){
if(self::$error_behavior == self::ERROR) {
user_error('Couldn\'t decode HTML when processing short codes', E_USER_ERRROR);
}
@@ -569,15 +524,11 @@ public function parse($content) {
}
}
- $doc = $bases->item(0)->ownerDocument;
-
- $xp = new DOMXPath($doc);
-
// First, replace any shortcodes that are in attributes
- $this->replaceAttributeTagsWithContent($doc);
+ $this->replaceAttributeTagsWithContent($htmlvalue);
// Find all the element scoped shortcode markers
- $shortcodes = $xp->query('//img[@class="'.self::$marker_class.'"]');
+ $shortcodes = $htmlvalue->query('//img[@class="'.self::$marker_class.'"]');
// Find the parents. Do this before DOM modification, since SPLIT might cause parents to move otherwise
$parents = $this->findParentsForMarkers($shortcodes);
@@ -605,8 +556,8 @@ public function parse($content) {
$this->replaceMarkerWithContent($shortcode, $tag);
}
-
- return $this->saveHTML($doc);
+
+ return $htmlvalue->getContent();
}
114 thirdparty/html5lib/HTML5/Data.php
View
@@ -1,114 +0,0 @@
-<?php
-
-// warning: this file is encoded in UTF-8!
-
-class HTML5_Data
-{
-
- // at some point this should be moved to a .ser file. Another
- // possible optimization is to give UTF-8 bytes, not Unicode
- // codepoints
- // XXX: Not quite sure why it's named this; this is
- // actually the numeric entity dereference table.
- protected static $realCodepointTable = array(
- 0x00 => 0xFFFD, // REPLACEMENT CHARACTER
- 0x0D => 0x000A, // LINE FEED (LF)
- 0x80 => 0x20AC, // EURO SIGN ('€')
- 0x81 => 0x0081, // <control>
- 0x82 => 0x201A, // SINGLE LOW-9 QUOTATION MARK ('‚')
- 0x83 => 0x0192, // LATIN SMALL LETTER F WITH HOOK ('ƒ')
- 0x84 => 0x201E, // DOUBLE LOW-9 QUOTATION MARK ('„')
- 0x85 => 0x2026, // HORIZONTAL ELLIPSIS ('…')
- 0x86 => 0x2020, // DAGGER ('†')
- 0x87 => 0x2021, // DOUBLE DAGGER ('‡')
- 0x88 => 0x02C6, // MODIFIER LETTER CIRCUMFLEX ACCENT ('ˆ')
- 0x89 => 0x2030, // PER MILLE SIGN ('‰')
- 0x8A => 0x0160, // LATIN CAPITAL LETTER S WITH CARON ('Š')
- 0x8B => 0x2039, // SINGLE LEFT-POINTING ANGLE QUOTATION MARK ('‹')
- 0x8C => 0x0152, // LATIN CAPITAL LIGATURE OE ('Œ')
- 0x8D => 0x008D, // <control>
- 0x8E => 0x017D, // LATIN CAPITAL LETTER Z WITH CARON ('Ž')
- 0x8F => 0x008F, // <control>
- 0x90 => 0x0090, // <control>
- 0x91 => 0x2018, // LEFT SINGLE QUOTATION MARK ('‘')
- 0x92 => 0x2019, // RIGHT SINGLE QUOTATION MARK ('’')
- 0x93 => 0x201C, // LEFT DOUBLE QUOTATION MARK ('“')
- 0x94 => 0x201D, // RIGHT DOUBLE QUOTATION MARK ('”')
- 0x95 => 0x2022, // BULLET ('•')
- 0x96 => 0x2013, // EN DASH ('–')
- 0x97 => 0x2014, // EM DASH ('—')
- 0x98 => 0x02DC, // SMALL TILDE ('˜')
- 0x99 => 0x2122, // TRADE MARK SIGN ('™')
- 0x9A => 0x0161, // LATIN SMALL LETTER S WITH CARON ('š')
- 0x9B => 0x203A, // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK ('›')
- 0x9C => 0x0153, // LATIN SMALL LIGATURE OE ('œ')
- 0x9D => 0x009D, // <control>
- 0x9E => 0x017E, // LATIN SMALL LETTER Z WITH CARON ('ž')
- 0x9F => 0x0178, // LATIN CAPITAL LETTER Y WITH DIAERESIS ('Ÿ')
- );
-
- protected static $namedCharacterReferences;
-
- protected static $namedCharacterReferenceMaxLength;
-
- /**
- * Returns the "real" Unicode codepoint of a malformed character
- * reference.
- */
- public static function getRealCodepoint($ref) {
- if (!isset(self::$realCodepointTable[$ref])) return false;
- else return self::$realCodepointTable[$ref];
- }
-
- public static function getNamedCharacterReferences() {
- if (!self::$namedCharacterReferences) {
- self::$namedCharacterReferences = unserialize(
- file_get_contents(dirname(__FILE__) . '/named-character-references.ser'));
- }
- return self::$namedCharacterReferences;
- }
-
- /**
- * Converts a Unicode codepoint to sequence of UTF-8 bytes.
- * @note Shamelessly stolen from HTML Purifier, which is also
- * shamelessly stolen from Feyd (which is in public domain).
- */
- public static function utf8chr($code) {
- /* We don't care: we live dangerously
- * if($code > 0x10FFFF or $code < 0x0 or
- ($code >= 0xD800 and $code <= 0xDFFF) ) {
- // bits are set outside the "valid" range as defined
- // by UNICODE 4.1.0
- return "\xEF\xBF\xBD";
- }*/
-
- $x = $y = $z = $w = 0;
- if ($code < 0x80) {
- // regular ASCII character
- $x = $code;
- } else {
- // set up bits for UTF-8
- $x = ($code & 0x3F) | 0x80;
- if ($code < 0x800) {
- $y = (($code & 0x7FF) >> 6) | 0xC0;
- } else {
- $y = (($code & 0xFC0) >> 6) | 0x80;
- if($code < 0x10000) {
- $z = (($code >> 12) & 0x0F) | 0xE0;
- } else {
- $z = (($code >> 12) & 0x3F) | 0x80;
- $w = (($code >> 18) & 0x07) | 0xF0;
- }
- }
- }
- // set up the actual character
- $ret = '';
- if($w) $ret .= chr($w);
- if($z) $ret .= chr($z);
- if($y) $ret .= chr($y);
- $ret .= chr($x);
-
- return $ret;
- }
-
-}
284 thirdparty/html5lib/HTML5/InputStream.php
View
@@ -1,284 +0,0 @@
-<?php
-
-/*
-
-Copyright 2009 Geoffrey Sneddon <http://gsnedders.com/>
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-
-// Some conventions:
-// /* */ indicates verbatim text from the HTML 5 specification
-// // indicates regular comments
-
-class HTML5_InputStream {
- /**
- * The string data we're parsing.
- */
- private $data;
-
- /**
- * The current integer byte position we are in $data
- */
- private $char;
-
- /**
- * Length of $data; when $char === $data, we are at the end-of-file.
- */
- private $EOF;
-
- /**
- * Parse errors.
- */
- public $errors = array();
-
- /**
- * @param $data Data to parse
- */
- public function __construct($data) {
-
- /* Given an encoding, the bytes in the input stream must be
- converted to Unicode characters for the tokeniser, as
- described by the rules for that encoding, except that the
- leading U+FEFF BYTE ORDER MARK character, if any, must not
- be stripped by the encoding layer (it is stripped by the rule below).
-
- Bytes or sequences of bytes in the original byte stream that
- could not be converted to Unicode characters must be converted
- to U+FFFD REPLACEMENT CHARACTER code points. */
-
- // XXX currently assuming input data is UTF-8; once we
- // build encoding detection this will no longer be the case
- //
- // We previously had an mbstring implementation here, but that
- // implementation is heavily non-conforming, so it's been
- // omitted.
- if (extension_loaded('iconv')) {
- // non-conforming
- $data = @iconv('UTF-8', 'UTF-8//IGNORE', $data);
- } else {
- // we can make a conforming native implementation
- throw new Exception('Not implemented, please install mbstring or iconv');
- }
-
- /* One leading U+FEFF BYTE ORDER MARK character must be
- ignored if any are present. */
- if (substr($data, 0, 3) === "\xEF\xBB\xBF") {
- $data = substr($data, 3);
- }
-
- /* All U+0000 NULL characters in the input must be replaced
- by U+FFFD REPLACEMENT CHARACTERs. Any occurrences of such
- characters is a parse error. */
- for ($i = 0, $count = substr_count($data, "\0"); $i < $count; $i++) {
- $this->errors[] = array(
- 'type' => HTML5_Tokenizer::PARSEERROR,
- 'data' => 'null-character'
- );
- }
- /* U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED
- (LF) characters are treated specially. Any CR characters
- that are followed by LF characters must be removed, and any
- CR characters not followed by LF characters must be converted
- to LF characters. Thus, newlines in HTML DOMs are represented
- by LF characters, and there are never any CR characters in the
- input to the tokenization stage. */
- $data = str_replace(
- array(
- "\0",
- "\r\n",
- "\r"
- ),
- array(
- "\xEF\xBF\xBD",
- "\n",
- "\n"
- ),
- $data
- );
-
- /* Any occurrences of any characters in the ranges U+0001 to
- U+0008, U+000B, U+000E to U+001F, U+007F to U+009F,
- U+D800 to U+DFFF , U+FDD0 to U+FDEF, and
- characters U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF,
- U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE, U+5FFFF, U+6FFFE,
- U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF, U+9FFFE, U+9FFFF,
- U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE, U+CFFFF, U+DFFFE,
- U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF, U+10FFFE, and
- U+10FFFF are parse errors. (These are all control characters
- or permanently undefined Unicode characters.) */
- // Check PCRE is loaded.
- if (extension_loaded('pcre')) {
- $count = preg_match_all(
- '/(?:
- [\x01-\x08\x0B\x0E-\x1F\x7F] # U+0001 to U+0008, U+000B, U+000E to U+001F and U+007F
- |
- \xC2[\x80-\x9F] # U+0080 to U+009F
- |
- \xED(?:\xA0[\x80-\xFF]|[\xA1-\xBE][\x00-\xFF]|\xBF[\x00-\xBF]) # U+D800 to U+DFFFF
- |
- \xEF\xB7[\x90-\xAF] # U+FDD0 to U+FDEF
- |
- \xEF\xBF[\xBE\xBF] # U+FFFE and U+FFFF
- |
- [\xF0-\xF4][\x8F-\xBF]\xBF[\xBE\xBF] # U+nFFFE and U+nFFFF (1 <= n <= 10_{16})
- )/x',
- $data,
- $matches
- );
- for ($i = 0; $i < $count; $i++) {
- $this->errors[] = array(
- 'type' => HTML5_Tokenizer::PARSEERROR,
- 'data' => 'invalid-codepoint'
- );
- }
- } else {
- // XXX: Need non-PCRE impl, probably using substr_count
- }
-
- $this->data = $data;
- $this->char = 0;
- $this->EOF = strlen($data);
- }
-
- /**
- * Returns the current line that the tokenizer is at.
- */
- public function getCurrentLine() {
- // Check the string isn't empty
- if($this->EOF) {
- // Add one to $this->char because we want the number for the next
- // byte to be processed.
- return substr_count($this->data, "\n", 0, min($this->char, $this->EOF)) + 1;
- } else {
- // If the string is empty, we are on the first line (sorta).
- return 1;
- }
- }
-
- /**
- * Returns the current column of the current line that the tokenizer is at.
- */
- public function getColumnOffset() {
- // strrpos is weird, and the offset needs to be negative for what we
- // want (i.e., the last \n before $this->char). This needs to not have
- // one (to make it point to the next character, the one we want the
- // position of) added to it because strrpos's behaviour includes the
- // final offset byte.
- $lastLine = strrpos($this->data, "\n", $this->char - 1 - strlen($this->data));
-
- // However, for here we want the length up until the next byte to be
- // processed, so add one to the current byte ($this->char).
- if($lastLine !== false) {
- $findLengthOf = substr($this->data, $lastLine + 1, $this->char - 1 - $lastLine);
- } else {
- $findLengthOf = substr($this->data, 0, $this->char);
- }
-
- // Get the length for the string we need.
- if(extension_loaded('iconv')) {
- return iconv_strlen($findLengthOf, 'utf-8');
- } elseif(extension_loaded('mbstring')) {
- return mb_strlen($findLengthOf, 'utf-8');
- } elseif(extension_loaded('xml')) {
- return strlen(utf8_decode($findLengthOf));
- } else {
- $count = count_chars($findLengthOf);
- // 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)
- // 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)
- return array_sum(array_slice($count, 0, 0x80)) +
- array_sum(array_slice($count, 0xC2, 0x33));
- }
- }
-
- /**
- * Retrieve the currently consume character.
- * @note This performs bounds checking
- */
- public function char() {
- return ($this->char++ < $this->EOF)
- ? $this->data[$this->char - 1]
- : false;
- }
-
- /**
- * Get all characters until EOF.
- * @note This performs bounds checking
- */
- public function remainingChars() {
- if($this->char < $this->EOF) {
- $data = substr($this->data, $this->char);
- $this->char = $this->EOF;
- return $data;
- } else {
- return false;
- }
- }
-
- /**
- * Matches as far as possible until we reach a certain set of bytes
- * and returns the matched substring.
- * @param $bytes Bytes to match.
- */
- public function charsUntil($bytes, $max = null) {
- if ($this->char < $this->EOF) {
- if ($max === 0 || $max) {
- $len = strcspn($this->data, $bytes, $this->char, $max);
- } else {
- $len = strcspn($this->data, $bytes, $this->char);
- }
- $string = (string) substr($this->data, $this->char, $len);
- $this->char += $len;
- return $string;
- } else {
- return false;
- }
- }
-
- /**
- * Matches as far as possible with a certain set of bytes
- * and returns the matched substring.
- * @param $bytes Bytes to match.
- */
- public function charsWhile($bytes, $max = null) {
- if ($this->char < $this->EOF) {
- if ($max === 0 || $max) {
- $len = strspn($this->data, $bytes, $this->char, $max);
- } else {
- $len = strspn($this->data, $bytes, $this->char);
- }
- $string = (string) substr($this->data, $this->char, $len);
- $this->char += $len;
- return $string;
- } else {
- return false;
- }
- }
-
- /**
- * Unconsume one character.
- */
- public function unget() {
- if ($this->char <= $this->EOF) {
- $this->char--;
- }
- }
-}
36 thirdparty/html5lib/HTML5/Parser.php
View
@@ -1,36 +0,0 @@
-<?php
-
-require_once dirname(__FILE__) . '/Data.php';
-require_once dirname(__FILE__) . '/InputStream.php';
-require_once dirname(__FILE__) . '/TreeBuilder.php';
-require_once dirname(__FILE__) . '/Tokenizer.php';
-
-/**
- * Outwards facing interface for HTML5.
- */
-class HTML5_Parser
-{
- /**
- * Parses a full HTML document.
- * @param $text HTML text to parse
- * @param $builder Custom builder implementation
- * @return Parsed HTML as DOMDocument
- */
- static public function parse($text, $builder = null) {
- $tokenizer = new HTML5_Tokenizer($text, $builder);
- $tokenizer->parse();
- return $tokenizer->save();
- }
- /**
- * Parses an HTML fragment.
- * @param $text HTML text to parse
- * @param $context String name of context element to pretend parsing is in.
- * @param $builder Custom builder implementation
- * @return Parsed HTML as DOMDocument
- */
- static public function parseFragment($text, $context = null, $builder = null) {
- $tokenizer = new HTML5_Tokenizer($text, $builder);
- $tokenizer->parseFragment($context);
- return $tokenizer->save();
- }
-}
2,422 thirdparty/html5lib/HTML5/Tokenizer.php
View
0 additions, 2,422 deletions not shown
3,841 thirdparty/html5lib/HTML5/TreeBuilder.php
View
0 additions, 3,841 deletions not shown
1  thirdparty/html5lib/HTML5/named-character-references.ser
View
0 additions, 1 deletion not shown
22 thirdparty/html5lib/LICENSE
View
@@ -1,22 +0,0 @@
-Copyright (c) 2006-2011 The Authors
-
-Contributors:
-James Graham - jg307@cam.ac.uk
-Anne van Kesteren - annevankesteren@gmail.com
-Lachlan Hunt - lachlan.hunt@lachy.id.au
-Matt McDonald - kanashii@kanashii.ca
-Sam Ruby - rubys@intertwingly.net
-Ian Hickson (Google) - ian@hixie.ch
-Thomas Broyer - t.broyer@ltgt.net
-Jacques Distler - distler@golem.ph.utexas.edu
-Henri Sivonen - hsivonen@iki.fi
-Adam Barth - abarth@webkit.org
-Eric Seidel - eric@webkit.org
-The Mozilla Foundation (contributions from Henri Sivonen since 2008)
-David Flanagan (Mozilla) - dflanagan@mozilla.com
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47 thirdparty/html5lib/README
View
@@ -1,47 +0,0 @@
-html5lib - php flavour
-
-This is an implementation of the tokenization and tree-building parts
-of the HTML5 specification in PHP. Potential uses of this library
-can be found in web-scrapers and HTML filters.
-
-Warning: This is a pre-alpha release, and as such, certain parts of
-this code are not up-to-snuff (e.g. error reporting and performance).
-However, the code is very close to spec and passes 100% of tests
-not related to parse errors. Nevertheless, expect to have to update
-your code on the next upgrade.
-
-
-Usage notes:
-
- <?php
- require_once '/path/to/HTML5/Parser.php';
- $dom = HTML5_Parser::parse('<html><body>...');
- $nodelist = HTML5_Parser::parseFragment('<b>Boo</b><br>');
- $nodelist = HTML5_Parser::parseFragment('<td>Bar</td>', 'table');
-
-
-Documentation:
-
-HTML5_Parser::parse($text)
- $text : HTML to parse
- return : DOMDocument of parsed document
-
-HTML5_Parser::parseFragment($text, $context)
- $text : HTML to parse
- $context : String name of context element
- return : DOMDocument of parsed document
-
-
-Developer notes:
-
-* To setup unit tests, you need to add a small stub file test-settings.php
- that contains $simpletest_location = 'path/to/simpletest/'; This needs to
- be version 1.1 (or, until that is released, SVN trunk) of SimpleTest.
-
-* We don't want to ultimately use PHP's DOM because it is not tolerant
- of certain types of errors that HTML 5 allows (for example, an element
- "foo@bar"). But the current implementation uses it, since it's easy.
- Eventually, this html5lib implementation will get a version of SimpleTree;
- and may possibly start using that by default.
-
- vim: et sw=4 sts=4
Please sign in to comment.
Something went wrong with that request. Please try again.