Constructor
new ConstrainedText(args)
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
Object | Options. Properties
|
- Source:
Members
(static) _types
fromSelSer
with.
List of types we attempt fromSelSer
with. This should include all the
concrete subclasses of ConstrainedText
(RegExpConstrainedText
is
missing since it is an abstract class). We also include the
ConstrainedText
class as the first element (even though it is
an abstract base class) as a little bit of a hack: it simplifies
ConstrainedText.fromSelSer
by factoring some of its work into
ConstrainedText._fromSelSer
.
- Source:
Methods
(static) cast(o, node) → {ConstrainedText}
Ensure that the argument o
, which is perhaps a string, is a instance of
ConstrainedText
.
Ensure that the argument o
, which is perhaps a string, is a instance of
ConstrainedText
.
Parameters:
Name | Type | Description |
---|---|---|
o |
string | ConstrainedText | |
node |
Node | The DOM Node corresponding to |
- Source:
Returns:
- Type
- ConstrainedText
(static) escapeLine(line) → {string}
This adds necessary escapes to a line of chunks. We provide
the ConstrainedText#escape
function with its left and right
context, and it can determine what escapes are needed.
The line
parameter is an array of ConstrainedText
chunks
which make up a line (or part of a line, in some cases of nested
processing).
Parameters:
Name | Type | Description |
---|---|---|
line |
Array.<ConstrainedText> |
- Source:
Returns:
- Type
- string
(static) fromSelSer(text, node, dataParsoid, env, opts)
SelSer support: when we come across an unmodified node in during selective serialization, we know we can use the original wikitext for that node unmodified.
SelSer support: when we come across an unmodified node in during selective serialization, we know we can use the original wikitext for that node unmodified. But there may be boundary conditions on the left and right sides of the selser'ed text which are going to require escaping.
So rather than turning the node into a plain old ConstrainedText
chunk, allow subclasses of ConstrainedText
to register as potential
handlers of selser nodes. A selser'ed magic link, for example,
will then turn into a MagicLinkText
and thus be able to enforce
the proper boundary constraints.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | |
node |
Node | |
dataParsoid |
Object | |
env |
MWParserEnvironment | |
opts |
Object |
- Source:
equals(ct) → {boolean}
Simple equality. This enforces type equality (ie subclasses are not equal).
Parameters:
Name | Type | Description |
---|---|---|
ct |
Object |
- Source:
Returns:
- Type
- boolean
escape(state) → {Object|string|string|string}
Use the provided state
, which gives context and access to the entire
list of chunks, to determine the proper escape prefix/suffix.
Use the provided state
, which gives context and access to the entire
list of chunks, to determine the proper escape prefix/suffix.
Returns an object with a text
property as well as optional
prefix
and 'suffix' properties giving desired escape strings.
Parameters:
Name | Type | Description |
---|---|---|
state |
Object |
- Source:
Returns:
-
- Type
- Object
-
Return.text.
- Type
- string
-
[return.prefix].
- Type
- string
-
[return.suffix].
- Type
- string