-
Notifications
You must be signed in to change notification settings - Fork 2
OnlyincludeToken
bhsd edited this page Jun 21, 2024
·
13 revisions
被<onlyinclude>
和</onlyinclude>
包裹的内容。仅在嵌入时(即 Parser.parse(text, true)
)生效。
✅ 在 Mini 和 Browser 版本中可用。
🌐 在 Browser 版本中可用。
✅ 展开
type: 'onlyinclude'
// type
var {firstChild} = Parser.parse('<onlyinclude>a</onlyinclude>', true);
assert.equal(firstChild, '<onlyinclude>a</onlyinclude>');
assert.strictEqual(firstChild.type, 'onlyinclude');
type: string
内部wikitext。
// innerText (main)
var {firstChild} = Parser.parse('<onlyinclude>a</onlyinclude>', true);
assert.equal(firstChild, '<onlyinclude>a</onlyinclude>');
assert.strictEqual(firstChild.innerText, 'a');
firstChild.innerText = '[[a]]';
assert.equal(firstChild, '<onlyinclude>[[a]]</onlyinclude>');
assert.strictEqual(firstChild.firstChild.type, 'link');
🌐 展开
returns: string
以HTML格式输出。
// print
var {firstChild} = Parser.parse('<onlyinclude>a</onlyinclude>', true);
assert.equal(
firstChild.print(),
`<span class="wpb-onlyinclude"><span class="wpb-ext"><onlyinclude></span>a<span class="wpb-ext"></onlyinclude></span></span>`,
);
returns: this
深拷贝节点。
// cloneNode (main)
var {firstChild} = Parser.parse('<onlyinclude>a</onlyinclude>', true);
assert.deepStrictEqual(firstChild.cloneNode(), firstChild);
对维基文本批量执行语法检查的命令行工具
用于维基文本的 ESLint 插件
A command-line tool that performs linting on Wikitext in bulk
ESLint plugin for Wikitext