]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blobdiff - vendor/wikimedia/remex-html/RemexHtml/Serializer/Formatter.php
MediaWiki 1.30.2
[autoinstalls/mediawiki.git] / vendor / wikimedia / remex-html / RemexHtml / Serializer / Formatter.php
diff --git a/vendor/wikimedia/remex-html/RemexHtml/Serializer/Formatter.php b/vendor/wikimedia/remex-html/RemexHtml/Serializer/Formatter.php
new file mode 100644 (file)
index 0000000..9a2f4fb
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+
+namespace RemexHtml\Serializer;
+use RemexHtml\Tokenizer\Attributes;
+
+/**
+ * The interface for classes that help Serializer to convert nodes to strings.
+ * Serializer assumes that the return values of these functions can be
+ * concatenated to make a document.
+ *
+ * It is not safe to assume that the methods will be called in any particular
+ * order, or that the return values will actually be retained in the final
+ * Serializer result.
+ */
+interface Formatter {
+       /**
+        * Get a string which starts the document
+        *
+        * @param string|null $fragmentNamespace
+        * @param string|null $fragmentName
+        * @return string
+        */
+       function startDocument( $fragmentNamespace, $fragmentName );
+
+       /**
+        * Encode the given character substring
+        *
+        * @param SerializerNode $parent The parent of the text node (at creation time)
+        * @param string $text
+        * @param integer $start The offset within $text
+        * @param integer $length The number of bytes within $text
+        * @return string
+        */
+       function characters( SerializerNode $parent, $text, $start, $length );
+
+       /**
+        * Encode the given element
+        *
+        * @param SerializerNode $parent The parent of the node (when it is closed)
+        * @param SerializerNode $node The element to encode
+        * @param string|null $contents The previously-encoded contents, or null
+        *   for a void element. Void elements can be serialized as self-closing
+        *   tags.
+        * @return string
+        */
+       function element( SerializerNode $parent, SerializerNode $node, $contents );
+
+       /**
+        * Encode a comment
+        * @param SerializerNode $parent The parent of the node (at creation time)
+        * @param string $text The inner text of the comment
+        * @return string
+        */
+       function comment( SerializerNode $parent, $text );
+
+       /**
+        * Encode a doctype. This event occurs when the source document has a doctype,
+        * it can return an empty string if the formatter wants to use its own doctype.
+        *
+        * @param string $name The doctype name, usually "html"
+        * @param string $public The PUBLIC identifier
+        * @param string $system The SYSTEM identifier
+        * @return string
+        */
+       function doctype( $name, $public, $system );
+}