]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - vendor/wikimedia/remex-html/RemexHtml/Serializer/Formatter.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / vendor / wikimedia / remex-html / RemexHtml / Serializer / Formatter.php
1 <?php
2
3 namespace RemexHtml\Serializer;
4 use RemexHtml\Tokenizer\Attributes;
5
6 /**
7  * The interface for classes that help Serializer to convert nodes to strings.
8  * Serializer assumes that the return values of these functions can be
9  * concatenated to make a document.
10  *
11  * It is not safe to assume that the methods will be called in any particular
12  * order, or that the return values will actually be retained in the final
13  * Serializer result.
14  */
15 interface Formatter {
16         /**
17          * Get a string which starts the document
18          *
19          * @param string|null $fragmentNamespace
20          * @param string|null $fragmentName
21          * @return string
22          */
23         function startDocument( $fragmentNamespace, $fragmentName );
24
25         /**
26          * Encode the given character substring
27          *
28          * @param SerializerNode $parent The parent of the text node (at creation time)
29          * @param string $text
30          * @param integer $start The offset within $text
31          * @param integer $length The number of bytes within $text
32          * @return string
33          */
34         function characters( SerializerNode $parent, $text, $start, $length );
35
36         /**
37          * Encode the given element
38          *
39          * @param SerializerNode $parent The parent of the node (when it is closed)
40          * @param SerializerNode $node The element to encode
41          * @param string|null $contents The previously-encoded contents, or null
42          *   for a void element. Void elements can be serialized as self-closing
43          *   tags.
44          * @return string
45          */
46         function element( SerializerNode $parent, SerializerNode $node, $contents );
47
48         /**
49          * Encode a comment
50          * @param SerializerNode $parent The parent of the node (at creation time)
51          * @param string $text The inner text of the comment
52          * @return string
53          */
54         function comment( SerializerNode $parent, $text );
55
56         /**
57          * Encode a doctype. This event occurs when the source document has a doctype,
58          * it can return an empty string if the formatter wants to use its own doctype.
59          *
60          * @param string $name The doctype name, usually "html"
61          * @param string $public The PUBLIC identifier
62          * @param string $system The SYSTEM identifier
63          * @return string
64          */
65         function doctype( $name, $public, $system );
66 }