-
Notifications
You must be signed in to change notification settings - Fork 2
ConverterFlagsToken (EN)
Table of Contents
Flags of language conversion.
✅ Available in the Mini and Browser versions.
Expand
type: Set<string>
All conversion flags.
// flags (main)
var flags = Parser.parse('-{H|}-').querySelector('converter-flags');
assert.deepStrictEqual(flags.flags, new Set(['H']));
flags.flags = new Set(['R']);
assert.equal(flags, 'R');
✅ Expand
returns: Set<string>
Get unknown conversion flags.
// getUnknownFlags
var flags = Parser.parse('-{{{{a}}}|}-').querySelector('converter-flags');
assert.deepStrictEqual(flags.getUnknownFlags(), new Set(['{{{a}}}']));
✅ Expand
returns: Set<string>
Get conversion flags of language variants.
// getVariantFlags
var flags = Parser.parse('-{zh-cn|}-').querySelector('converter-flags');
assert.deepStrictEqual(flags.getVariantFlags(), new Set(['zh-cn']));
✅ Expand
returns: LintError[]
Report potential grammar errors.
// lint
var flags = Parser.parse('-{h|}-').querySelector('converter-flags');
assert.deepStrictEqual(flags.lint(), [
{
rule: 'no-ignored',
severity: 'error',
message: 'invalid conversion flag',
startLine: 0,
startCol: 2,
startIndex: 2,
endLine: 0,
endCol: 3,
endIndex: 3,
fix: {
range: [2, 3],
text: 'H',
desc: 'uppercase',
},
},
]);
Expand
returns: this
Deep clone the node.
// cloneNode (main)
var flags = Parser.parse('-{}-').querySelector('converter-flags');
assert.deepStrictEqual(flags.cloneNode(), flags);
Expand
returns: Set<string>
Get all conversion flags.
// getAllFlags (main)
var flags = Parser.parse('-{A|}-').querySelector('converter-flags');
assert.deepStrictEqual(flags.getAllFlags(), new Set(['A']));
Expand
param: string
conversion flag
returns: Token[]
Get conversion flag tokens.
// getFlagTokens (main)
var flags = Parser.parse('-{A|}-').querySelector('converter-flags');
assert.deepStrictEqual(flags.getFlagTokens('A'), [flags.firstChild]);
Expand
returns: Set<string>
Get effective conversion flags.
// getEffectiveFlags (main)
var flags = Parser.parse('-{}-').querySelector('converter-flags');
assert.deepStrictEqual(flags.getEffectiveFlags(), new Set(['S']));
Expand
param: string
conversion flag
returns: boolean
Whether it has a specific conversion flag.
// hasFlag (main)
var flags = Parser.parse('-{R|}-').querySelector('converter-flags');
assert(flags.hasFlag('R'));
flags.firstChild.replaceChildren('H');
assert(!flags.hasFlag('R'));
assert(flags.hasFlag('H'));
Expand
param: string
conversion flag
returns: boolean
Whether it has a specific effective conversion flag.
// hasEffectiveFlag (main)
var flags = Parser.parse('-{}-').querySelector('converter-flags');
assert(flags.hasEffectiveFlag('S'));
Expand
param: string
conversion flag
Remove a specific conversion flag.
// removeFlag (main)
var flags = Parser.parse('-{R|}-').querySelector('converter-flags');
flags.removeFlag('R');
assert.equal(flags, '');
Expand
param: string
conversion flag
Add a specific conversion flag.
// setFlag (main)
var flags = Parser.parse('-{}-').querySelector('converter-flags');
flags.setFlag('R');
assert.equal(flags, 'R');
Expand
param: string
conversion flag
Toggle a specific conversion flag.
// toggleFlag (main)
var flags = Parser.parse('-{R|}-').querySelector('converter-flags');
flags.toggleFlag('R');
flags.toggleFlag('D');
assert.equal(flags, 'D');
对维基文本批量执行语法检查的命令行工具
用于维基文本的 ESLint 插件
A command-line tool that performs linting on Wikitext in bulk
ESLint plugin for Wikitext