-
Notifications
You must be signed in to change notification settings - Fork 2
ConverterRuleToken
bhsd edited this page Nov 24, 2023
·
12 revisions
单条转换规则。
- 规则对应的语言变体。
var root = Parser.parse('-{繁體=>zh-hans:繁体}-'),
converterRule = root.querySelector('converter-rule');
assert.strictEqual(converterRule.variant, 'zh-hans');
- 是否是单向转换。
var root = Parser.parse('-{繁體=>zh-hans:繁体}-'),
converterRule = root.querySelector('converter-rule');
assert(converterRule.unidirectional === true);
- 是否是双向转换。
var root = Parser.parse('-{zh-hans:繁体}-'),
converterRule = root.querySelector('converter-rule');
assert(converterRule.bidirectional === true);
- 更改规则使得内容不会转换。
var root = Parser.parse('-{繁體=>zh-hans:繁體}-'),
converterRule = root.querySelector('converter-rule');
converterRule.noConvert();
assert.strictEqual(root.toString(), '-{繁體}-');
- 修改转换结果。
var root = Parser.parse('-{繁體=>zh-hans:繁體}-'),
converterRule = root.querySelector('converter-rule');
converterRule.setTo('繁体');
assert.strictEqual(root.toString(), '-{繁體=>zh-hans:繁体}-');
setVariant(variant: string): void
- 修改转换规则对应的语言变体。
var root = Parser.parse('-{繁體=>zh-hans:繁體}-'),
converterRule = root.querySelector('converter-rule');
converterRule.setVariant('zh-cn');
assert.strictEqual(root.toString(), '-{繁體=>zh-cn:繁體}-');
- 对单项转换规则,修改待转换的内容。
var root = Parser.parse('-{繁體=>zh-hans:繁体}-'),
converterRule = root.querySelector('converter-rule');
converterRule.setFrom('正體');
assert.strictEqual(root.toString(), '-{正體=>zh-hans:繁体}-');
makeUnidirectional(from: string): void
- setFrom 方法的別名,但这里再提供一个将双向转换规则改为单向转换的例子。
var root = Parser.parse('-{zh-hant:繁體;zh-hans:繁体}-'),
[hantRule, hansRule] = root.querySelectorAll('converter-rule');
hantRule.setFrom('正體');
hansRule.setFrom('正體');
assert.strictEqual(root.toString(), '-{正體=>zh-hant:繁體;正體=>zh-hans:繁体}-');
- 将规则改为双向转换。
var root = Parser.parse('-{繁體=>zh-hans:繁体}-'),
converterRule = root.querySelector('converter-rule');
converterRule.makeBidirectional();
assert.strictEqual(root.toString(), '-{zh-hans:繁体}-');
对维基文本批量执行语法检查的命令行工具
用于维基文本的 VSCode 扩展
A command-line tool that performs linting on Wikitext in bulk
VSCode extension for Wikitext