Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Utils Namespace Reference

This file contains general utilities for scripts in the bin/, tools/, tests/ directories. More...

Classes

class  CompatJsonCodec
 This is a "compatible" JSON codec for the use of Parsoid test runners, etc. More...
 
class  ComputeSelectiveStats
 This file contains code to classify opportunities for selective update and collect statistics. More...
 
class  ConfigUtils
 This refactors common code in Api and Mock based config computation. More...
 
class  ContentUtils
 These utilities are for processing content that's generated by parsing source input (ex: wikitext) More...
 
class  DiffDOMUtils
 Some diff marker aware DOM utils. More...
 
class  DOMCompat
 Helper class that provides missing DOM level 3 methods for the PHP DOM classes. More...
 
class  DOMDataCodec
 Customized subclass of JsonCodec for serialization of rich attributes. More...
 
class  DOMDataUtils
 These helpers pertain to HTML and data attributes of a node. More...
 
class  DOMPostOrder
 Non-recursive post-order traversal of a DOM tree. More...
 
class  DOMTraverser
 Class for helping us traverse the DOM. More...
 
class  DOMUtils
 DOM utilities for querying the DOM. More...
 
class  DTState
 State carried while DOM Traversing. More...
 
class  Histogram
 Histogram class is a helper class that creates appropriate histogram buckets for various metrics collected by Parsoid. More...
 
class  PHPUtils
 This file contains Parsoid-independent PHP helper functions. More...
 
class  PipelineUtils
 This file contains parsing pipeline related utilities. More...
 
interface  RichCodecable
 This is an extension of JsonCodecable which adds some properties useful for rich attributes: More...
 
class  ScriptUtils
 
class  Timing
 A helper class to make it easier to compute timing metrics. More...
 
class  Title
 
class  TitleException
 Exception thrown for invalid titles. More...
 
class  TitleValue
 Lightweight title class. More...
 
class  TokenUtils
 This class contains general utilities for: (a) querying token properties and token types (b) manipulating tokens, individually and as collections. More...
 
class  UrlUtils
 Utilities for manipulating URLs. More...
 
class  Utils
 This file contains general utilities for token transforms. More...
 
class  WTUtils
 These utilites pertain to querying / extracting / modifying wikitext information from the DOM. More...
 

Variables

trait JsonCodecableWithCodecTrait
 This is an implementation of JsonCodecableTrait which passes the JsonCodec along to the class.
 

Detailed Description

This file contains general utilities for scripts in the bin/, tools/, tests/ directories.

This file should not contain any helpers that are needed by code in the lib/ directory.

Variable Documentation

◆ JsonCodecableWithCodecTrait

trait Wikimedia::Parsoid::Utils\JsonCodecableWithCodecTrait
Initial value:
{
public static function jsonClassCodec(
JsonCodecInterface $codec, ContainerInterface $serviceContainer
): JsonClassCodec {
return new class( $codec ) implements JsonClassCodec {
public function __construct( private JsonCodecInterface $codec ) {
}
public function toJsonArray( $obj ): array {
return $obj->toJsonArray( $this->codec );
}
public function newFromJsonArray( string $className, array $json ) {
return $className::newFromJsonArray( $this->codec, $json );
}
public function jsonClassHintFor( string $className, string $keyName ) {
return $className::jsonClassHintFor( $keyName );
}
};
}
abstract public function toJsonArray( JsonCodecInterface $codec ): array

This is an implementation of JsonCodecableTrait which passes the JsonCodec along to the class.

This allows us to implement custom encodings for properties with DocumentFragment types by manually encoding the property.