Namespace: PipelineUtils

utils/PipelineUtils~PipelineUtils

Members

(static) expandValueToDOM

Expands value all the way to DOM and pass it back to a callback.

Expands value all the way to DOM and pass it back to a callback.

FIXME: More of the users of PipelineUtils.promiseToProcessContent and PipelineUtils.processContentInPipeline could be converted to use this method if we could find a good way to abstract the different use cases.

Source:

Methods

(static) addSpanWrappers(nodes)

Wrap text and comment nodes in a node list into spans, so that all top-level nodes are elements.

Wrap text and comment nodes in a node list into spans, so that all top-level nodes are elements.

Parameters:
Name Type Description
nodes Array.<Node>

List of DOM nodes to wrap, mix of node types.

Source:

(static) convertDOMtoTokens(tokBuf)

...
Parameters:
Name Type Description
tokBuf Array.<Token>

This is where the tokens get stored.

Source:

(static) encapsulateExpansionHTML(env, token, expansion, optsopt)

Generates wrapper tokens for a HTML expansion -- the wrapper tokens are placeholders that adequately represent semantics of the HTML DOM for the purposes of additional token transformations that will be applied to them.

Generates wrapper tokens for a HTML expansion -- the wrapper tokens are placeholders that adequately represent semantics of the HTML DOM for the purposes of additional token transformations that will be applied to them.

Parameters:
Name Type Attributes Description
env MWParserEnvironment

The active environment/context.

token Token

The token that generated the DOM.

expansion Object
Properties
Name Type Description
html string

HTML of the expansion.

nodes Array.<Node>

Outermost nodes of the HTML.

opts Object <optional>
Properties
Name Type Description
tsr Object

The TSR to set on the generated tokens. This TSR is used to compute DSR on the placeholder tokens. The computed DSR is transferred over to the unpacked DOM if setDSR is true (see below).

setDSR boolean

When the DOM fragment is unpacked, this option governs whether the DSR from the placeholder node is transferred over to the unpacked DOM or not. For example: Cite, reused transclusions.

fromCache boolean
pipelineOpts Object
sealFragment boolean
wrapperName string
Source:

(static) expandValuesToDOM()

See expandValueToDOM above.

See expandValueToDOM above.

Source:

(static) extractExpansions()

Extract transclusion and extension expansions from a DOM, and return them in a structure like this:

    {
        transclusions: {
            'key1': {
                 html: 'html1',
                 nodes: [<node1>, <node2>]
            }
        },
        extensions: {
            'key2': {
                 html: 'html2',
                 nodes: [<node1>, <node2>]
            }
        },
        files: {
            'key3': {
                 html: 'html3',
                 nodes: [<node1>, <node2>]
            }
        }
    }
.

Extract transclusion and extension expansions from a DOM, and return them in a structure like this:

    {
        transclusions: {
            'key1': {
                 html: 'html1',
                 nodes: [<node1>, <node2>]
            }
        },
        extensions: {
            'key2': {
                 html: 'html2',
                 nodes: [<node1>, <node2>]
            }
        },
        files: {
            'key3': {
                 html: 'html3',
                 nodes: [<node1>, <node2>]
            }
        }
    }
Source:

(static) getDOMFragmentToken(content, srcOffsets, optsopt)

Creates a dom-fragment-token for processing 'content' (an array of tokens) in its own subpipeline all the way to DOM.

Creates a dom-fragment-token for processing 'content' (an array of tokens) in its own subpipeline all the way to DOM. These tokens will be processed by their own handler (DOMFragmentBuilder) in the last stage of the async pipeline.

srcOffsets should always be provided to process top-level page content in a subpipeline. Without it, DSR computation and template wrapping cannot be done in the subpipeline. While unpackDOMFragment can do this on unwrapping, that can be a bit fragile and makes dom-fragments a leaky abstraction by leaking subpipeline processing into the top-level pipeline.

Parameters:
Name Type Attributes Description
content Array.<Token>

The array of tokens to process.

srcOffsets Array.<number>

Wikitext source offsets (start/end) of these tokens.

opts Object <optional>

Parsing options.

Properties
Name Type Description
contextTok Token

The token that generated the content.

inlineContext boolean

Is this DOM fragment used in an inline context?

inPHPBlock boolean

Is this DOM fragment used inside a "PHP Block" FIXME: This primarily exists for backward compatibility reasons and is likely to eventually go away.

Source:

(static) getWrapperTokens(nodes, opts) → {Array}

Get tokens representing a DOM forest (from transclusions, extensions, whatever that were generated as part of a separate processing pipeline) in the token stream.

Get tokens representing a DOM forest (from transclusions, extensions, whatever that were generated as part of a separate processing pipeline) in the token stream. These tokens will tunnel the subtree through the token processing while preserving token stream semantics as if the DOM had been converted to tokens.

Parameters:
Name Type Description
nodes Array.<Node>

List of DOM nodes that need to be tunneled through.

opts Object

See encapsulateExpansionHTML's doc. for more info about these options.

Source:
Returns:

List of token representatives.

Type
Array

(static) processContentInPipeline(env, frame, content, opts)

Processes content (wikitext, array of tokens, whatever) in its own pipeline based on options.

Processes content (wikitext, array of tokens, whatever) in its own pipeline based on options.

Parameters:
Name Type Description
env MWParserEnvironment

The environment/context for the expansion.

frame Object

The parent frame within which the expansion is taking place. This param is mostly defunct now that we are not doing native expansion anymore.

content Object

This could be wikitext or single token or an array of tokens. How this content is processed depends on what kind of pipeline is constructed specified by opts.

opts Object

Processing options that specify pipeline-type, opts, and callbacks.

Properties
Name Type Attributes Description
pipelineType string
pipelineOpts Object
tplArgs Object <optional>
Properties
Name Type Description
name string
attribs Array
srcOffsets Array <optional>
chunkCB function <optional>
endCB function <optional>
documentCB function <optional>
sol boolean
Source:

(static) promiseToProcessContent(env, frame, content, opts) → {Promise.<Document>}

A promise returning wrapper around processContentInPipeline that resolves with the docuemnt.

A promise returning wrapper around processContentInPipeline that resolves with the docuemnt.

Parameters:
Name Type Description
env MWParserEnvironment

The environment/context for the expansion.

frame Object

The parent frame within which the expansion is taking place. This param is mostly defunct now that we are not doing native expansion anymore.

content Object

This could be wikitext or single token or an array of tokens. How this content is processed depends on what kind of pipeline is constructed specified by opts.

opts Object

Processing options that specify pipeline-type, opts, and callbacks.

Properties
Name Type Attributes Description
pipelineType string
pipelineOpts Object
tplArgs Object <optional>
Properties
Name Type Description
name string
attribs Array
srcOffsets Array <optional>
sol boolean
Source:
Returns:
Type
Promise.<Document>

(static) tunnelDOMThroughTokens(env, token, body, opts)

Convert a HTML5 DOM into a mw:DOMFragment and generate appropriate tokens to insert into the token stream for further processing.

Convert a HTML5 DOM into a mw:DOMFragment and generate appropriate tokens to insert into the token stream for further processing.

The DOMPostProcessor will unpack the fragment and insert the HTML back into the DOM.

Parameters:
Name Type Description
env MWParserEnvironment

The active environment/context.

token Token

The token that generated the DOM.

body Node

The DOM that the token expanded to.

opts Object

Options to be passed onto the encapsulation code See encapsulateExpansionHTML's doc. for more info about these options.

Source: