- Source:
Members
(static) expandValueToDOM
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.
(static) convertDOMtoTokens(tokBuf)
(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
|
||||||||||||||||||||||
opts |
Object |
<optional> |
Properties
|
- Source:
(static) expandValuesToDOM()
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> | string | The array of tokens to process. |
|||||||||||||
srcOffsets |
Array.<number> | Wikitext source offsets (start/end) of these tokens. |
|||||||||||||
opts |
Object |
<optional> |
Parsing options. Properties
|
- 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
|
- 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
|
- Source:
Returns:
(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: