|
Parsoid
A bidirectional parser between wikitext and HTML5
|
An atomic fragment represented as a (prepared and loaded) DOM tree. More...
Inheritance diagram for Wikimedia\Parsoid\Fragments\DomPFragment:
Collaboration diagram for Wikimedia\Parsoid\Fragments\DomPFragment:Public Member Functions | |
| isEmpty () | |
| Returns true if this fragment is empty.This enables optimizations if implemented, but returns false by default. | |
| isValid () | |
| DomPFragments may become invalid when combined into other fragments. | |
| markInvalid () | |
| For ease of debugging, use ::markInvalid() to mark a DomPFragment that should not be (re)used. | |
| asDom (ParsoidExtensionAPI $extApi, bool $release=false) | |
Return the fragment as a (prepared and loaded) DOM DocumentFragment belonging to the Parsoid top-level document.If $release is true, then this PFragment will become invalid after this method returns.
| |
| asHtmlString (ParsoidExtensionAPI $extApi) | |
Return the fragment as a string of HTML.This method is very similar to asDom() but also supports fragmentary and unbalanced HTML, and therefore composition may yield unexpected results. This is a common type in legacy MediaWiki code, but use in new code should be discouraged. Data attributes will be represented as inline attributes, which may be suboptimal.
| |
| toJsonArray () | |
Public Member Functions inherited from Wikimedia\Parsoid\Fragments\PFragment | |
| isAtomic () | |
Returns true if this fragment contains no wikitext elements; that is, if ::asMarkedWikitext() given an empty strip state would return a single strip marker and add a single item to the strip state (representing $this). | |
| getSrcOffsets () | |
| Return the region of the source document that corresponds to this fragment. | |
| asMarkedWikitext (StripState $stripState) | |
| This method returns a "wikitext string" in the legacy format. | |
| containsMarker () | |
| Returns true if this fragment contains some non-wikitext content. | |
| split () | |
| Split this fragment at its strip markers and return an array which alternates between string items and PFragment items. | |
| killMarkers () | |
| Return a version of this fragment with all non-wikitext content removed. | |
| markerSkipCallback (callable $callback) | |
| Call a callback function on all regions of the given text that are wikitext content, replacing them with the return value of the callback. | |
| trim () | |
| Trim leading and trailing wikitext whitespace from this fragment. | |
| expand (ParsoidExtensionAPI $extApi, ?bool &$error=null) | |
| Expand templates, extension tags, and parser functions in a fragment. | |
| toRawText (ParsoidExtensionAPI $extApi) | |
| Return the 'raw text' of this fragment. | |
Static Public Member Functions | |||
| static | newFromDocumentFragment (DocumentFragment $df, ?DomSourceRange $srcOffsets) | ||
| Create a new DomPFragment from the given DocumentFragment and optional source string. | |||
| static | castFromPFragment (ParsoidExtensionAPI $ext, PFragment $fragment) | ||
| Return a DomPFragment corresponding to the given PFragment. | |||
| static | concat (ParsoidExtensionAPI $ext, bool $release, PFragment ... $fragments) | ||
| Return a DomPFragment representing the concatenation of the given fragments, as (balanced) DOM forests. | |||
| static | newFromJsonArray (array $json) | ||
| |||
| static | jsonClassHintFor (string $keyName) | ||
Static Public Member Functions inherited from Wikimedia\Parsoid\Fragments\PFragment | |||
| static | fromSplitWt (array $pieces, ?DomSourceRange $srcOffset=null) | ||
| Helper function to create a new fragment from a mixed array of strings and fragments. | |||
| static | registerFragmentClass (string $className) | ||
| Register a fragment type with the JSON deserialization code. | |||
| static | hint () | ||
Public Attributes | |
| const | TYPE_HINT = 'dom' |
Additional Inherited Members | |
Protected Member Functions inherited from Wikimedia\Parsoid\Fragments\PFragment | |
| __construct (?DomSourceRange $srcOffsets) | |
Static Protected Member Functions inherited from Wikimedia\Parsoid\Fragments\PFragment | |
| static | joinSourceRange (?DomSourceRange $first, ?DomSourceRange $second) |
| Helper function to append two source ranges. | |
Protected Attributes inherited from Wikimedia\Parsoid\Fragments\PFragment | |
| DomSourceRange | $srcOffsets |
The original wikitext source range for this fragment, or null for synthetic content that corresponds to no part of the original authored text. | |
Static Protected Attributes inherited from Wikimedia\Parsoid\Fragments\PFragment | |
| static array | $FRAGMENT_TYPES |
An atomic fragment represented as a (prepared and loaded) DOM tree.
| Wikimedia\Parsoid\Fragments\DomPFragment::asDom | ( | ParsoidExtensionAPI | $extApi, |
| bool | $release = false ) |
Return the fragment as a (prepared and loaded) DOM DocumentFragment belonging to the Parsoid top-level document.If $release is true, then this PFragment will become invalid after this method returns.
Reimplemented from Wikimedia\Parsoid\Fragments\PFragment.
| Wikimedia\Parsoid\Fragments\DomPFragment::asHtmlString | ( | ParsoidExtensionAPI | $extApi | ) |
Return the fragment as a string of HTML.This method is very similar to asDom() but also supports fragmentary and unbalanced HTML, and therefore composition may yield unexpected results. This is a common type in legacy MediaWiki code, but use in new code should be discouraged. Data attributes will be represented as inline attributes, which may be suboptimal.
Reimplemented from Wikimedia\Parsoid\Fragments\PFragment.
|
static |
Return a DomPFragment corresponding to the given PFragment.
If the fragment is not already a DomPFragment, this will convert it to a DocumentFragment using PFragment::asDom().
|
static |
Return a DomPFragment representing the concatenation of the given fragments, as (balanced) DOM forests.
The children of all fragments will be siblings in the result.
If $release is true, all $fragments arguments may become invalid. Otherwise, fragment contents will be cloned as necessary to avoid fragment invalidation.
| Wikimedia\Parsoid\Fragments\DomPFragment::isEmpty | ( | ) |
Returns true if this fragment is empty.This enables optimizations if implemented, but returns false by default.
Reimplemented from Wikimedia\Parsoid\Fragments\PFragment.
| Wikimedia\Parsoid\Fragments\DomPFragment::isValid | ( | ) |
DomPFragments may become invalid when combined into other fragments.
Reimplemented from Wikimedia\Parsoid\Fragments\PFragment.
|
static |
Reimplemented from Wikimedia\Parsoid\Fragments\PFragment.
|
static |
| JsonException |
Reimplemented from Wikimedia\Parsoid\Fragments\PFragment.
| Wikimedia\Parsoid\Fragments\DomPFragment::toJsonArray | ( | ) |
Reimplemented from Wikimedia\Parsoid\Fragments\PFragment.