Module: wt2html/pp/processors/computeDSR



For an explanation of what TSR is, see computeDSR.js.


(inner) computeDSR(rootNode, env, options)

Computes DSR ranges for every node of a DOM tree.

Computes DSR ranges for every node of a DOM tree.

Name Type Description
rootNode Object

The root of the tree for which DSR has to be computed.

env Object

The environment/context for the parse pipeline.

options Object

Options governing DSR computation sourceOffsets: [start, end] source offset. If missing, this defaults to [0,] attrExpansion: Is this an attribute expansion pipeline?


(inner) computeNodeDSR(env, node, s, e, dsrCorrection, opts)

Compute TSR for a Node.

Compute TSR for a Node.

TSR = "Tag Source Range". Start and end offsets giving the location where the tag showed up in the original source.

DSR = "DOM Source Range". [0] and [1] are open and end, [2] and [3] are widths of the container tag.

TSR is set by the tokenizer. In most cases, it only applies to the specific tag (opening or closing). However, for self-closing tags that the tokenizer generates, the TSR values applies to the entire DOM subtree (opening tag + content + closing tag).

Ex: So [[foo]] will get tokenized to a SelfClosingTagTk(...) with a TSR value of [0,7]. The DSR algorithm will then use that info and assign the a-tag rooted at the foo DOM subtree a DSR value of [0,7,2,2], where 2 and 2 refer to the opening and closing tag widths.

[s,e) -- if defined, start/end position of wikitext source that generated node's subtree

Name Type Description
env MWParserEnvironment
node Node

node to process

s number

start position, inclusive

e number

end position, exclusive

dsrCorrection number
opts Object