2 namespace Masterminds\HTML5\Parser;
5 * Standard events for HTML5.
7 * This is roughly analogous to a SAX2 or expat-style interface.
8 * However, it is tuned specifically for HTML5, according to section 8
9 * of the HTML5 specification.
11 * An event handler receives parser events. For a concrete
12 * implementation, see DOMTreeBuilder.
14 * Quirks support in the parser is limited to close-in syntax (malformed
15 * tags or attributes). Higher order syntax and semantic issues with a
16 * document (e.g. mismatched tags, illegal nesting, etc.) are the
17 * responsibility of the event handler implementation.
19 * See HTML5 spec section 8.2.4
21 interface EventHandler
24 const DOCTYPE_NONE = 0;
26 const DOCTYPE_PUBLIC = 1;
28 const DOCTYPE_SYSTEM = 2;
31 * A doctype declaration.
34 * The name of the root element.
36 * One of DOCTYPE_NONE, DOCTYPE_PUBLIC, or DOCTYPE_SYSTEM.
38 * The identifier. For DOCTYPE_PUBLIC, this is the public ID. If DOCTYPE_SYSTEM,
39 * then this is a system ID.
40 * @param boolean $quirks
41 * Indicates whether the builder should enter quirks mode.
43 public function doctype($name, $idType = 0, $id = null, $quirks = false);
48 * IMPORTANT: The parser watches the return value of this event. If this returns
49 * an integer, the parser will switch TEXTMODE patters according to the int.
51 * This is how the Tree Builder can tell the Tokenizer when a certain tag should
52 * cause the parser to go into RAW text mode.
54 * The HTML5 standard requires that the builder is the one that initiates this
55 * step, and this is the only way short of a circular reference that we can
58 * Example: if a startTag even for a `script` name is fired, and the startTag()
59 * implementation returns Tokenizer::TEXTMODE_RAW, then the tokenizer will
60 * switch into RAW text mode and consume data until it reaches a closing
63 * The textmode is automatically reset to Tokenizer::TEXTMODE_NORMAL when the
64 * closing tag is encounter. **This behavior may change.**
68 * @param array $attributes
69 * An array with all of the tag's attributes.
70 * @param boolean $selfClosing
71 * An indicator of whether or not this tag is self-closing (<foo/>)
72 * @return int One of the Tokenizer::TEXTMODE_* constants.
74 public function startTag($name, $attributes = array(), $selfClosing = false);
79 public function endTag($name);
82 * A comment section (unparsed character data).
84 public function comment($cdata);
87 * A unit of parsed character data.
89 * Entities in this text are *already decoded*.
91 public function text($cdata);
94 * Indicates that the document has been entirely processed.
96 public function eof();
99 * Emitted when the parser encounters an error condition.
101 public function parseError($msg, $line, $col);
106 * @param string $data
107 * The unparsed character data.
109 public function cdata($data);
112 * This is a holdover from the XML spec.
114 * While user agents don't get PIs, server-side does.
116 * @param string $name
117 * The name of the processor (e.g. 'php').
118 * @param string $data
121 public function processingInstruction($name, $data = null);