Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5974347
FastFormatter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
FastFormatter.php
View Options
<?php
namespace
Wikimedia\RemexHtml\Serializer
;
/**
* A formatter suitable for pre-sanitized input with ignoreEntities enabled
* in the Tokenizer.
*/
class
FastFormatter
implements
Formatter
{
public
function
__construct
(
$options
=
[]
)
{
}
/**
* @inheritDoc
*/
public
function
startDocument
(
$fragmentNamespace
,
$fragmentName
)
{
if
(
$fragmentNamespace
===
null
)
{
return
"<!DOCTYPE html>
\n
"
;
}
else
{
return
''
;
}
}
/**
* @inheritDoc
*/
public
function
doctype
(
$name
,
$public
,
$system
)
{
return
''
;
}
/**
* @inheritDoc
*/
public
function
characters
(
SerializerNode
$parent
,
$text
,
$start
,
$length
)
{
return
substr
(
$text
,
$start
,
$length
);
}
/**
* @inheritDoc
*/
public
function
element
(
SerializerNode
$parent
,
SerializerNode
$node
,
$contents
)
{
$name
=
$node
->
name
;
$ret
=
"<$name"
;
foreach
(
$node
->
attrs
->
getValues
()
as
$attrName
=>
$value
)
{
$ret
.=
" $attrName=
\"
$value
\"
"
;
}
if
(
$contents
===
null
)
{
$ret
.=
"/>"
;
}
elseif
(
isset
(
$contents
[
0
]
)
&&
$contents
[
0
]
===
"
\n
"
&&
in_array
(
$name
,
[
'pre'
,
'textarea'
,
'listing'
]
)
)
{
$ret
.=
">
\n
$contents</$name>"
;
}
else
{
$ret
.=
">$contents</$name>"
;
}
return
$ret
;
}
/**
* @inheritDoc
*/
public
function
comment
(
SerializerNode
$parent
,
$text
)
{
return
"<!--$text-->"
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 17:20 (1 d, 7 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
84/e2/f153502461d958dd9899b613b7c7
Default Alt Text
FastFormatter.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment