-
Notifications
You must be signed in to change notification settings - Fork 2
RedirectToken (EN)
bhsd edited this page Jun 26, 2024
·
2 revisions
Redirect, which is always at the very beginning of a page. RedirectToken inherits all the properties and methods of the Token class which are not repeated here.
✅ Available in the Mini and Browser versions.
🌐 Available in the Browser version.
✅ Expand
type: 'redirect'
// type
var {firstChild} = Parser.parse('#redirect [[a]]');
assert.equal(firstChild, '#redirect [[a]]');
assert.strictEqual(firstChild.type, 'redirect');
✅ Expand
returns: string
Redirect is invisible.
// text
var {firstChild} = Parser.parse('#redirect [[a]]');
assert.strictEqual(firstChild.text(), '');
🌐 Expand
returns: string
Output in HTML format.
// print
var {firstChild} = Parser.parse('\n#redirect [[a]]\n');
assert.equal(
firstChild.print(),
`<span class="wpb-redirect">
<span class="wpb-redirect-syntax">#redirect </span><span class="wpb-redirect-target">[[<span class="wpb-link-target">a</span>]]</span>
</span>`,
);
Expand
param: this
Deep clone the node.
// cloneNode (main)
var {firstChild} = Parser.parse('#redirect [[a|b]]');
assert.deepStrictEqual(firstChild.cloneNode(), firstChild);
Expand
version added: 1.10.0
returns: string
Convert to HTML.
// toHtml (main)
var {firstChild} = Parser.parse('#redirect [[a#b|c]]');
assert.strictEqual(
firstChild.toHtml(),
`<ul class="redirectText"><li><a href="/wiki/A#b" title="A">A#b</a></li></ul>`,
);
对维基文本批量执行语法检查的命令行工具
用于维基文本的 ESLint 插件
A command-line tool that performs linting on Wikitext in bulk
ESLint plugin for Wikitext