-
Notifications
You must be signed in to change notification settings - Fork 2
wikiparse.LanguageService (EN)
This is a global constructor added by the browser extension, which can be used as a language server for online editors such as Monaco (demo).
This class inherits all the properties and methods of the LanguageService class which are available in the 🌐 browser. Only the methods of which the types of parameters or return values have changed are listed below.
Expand
param: string
The wikitext content.
returns: Promise<ColorInformation[]>
List all color references found in the document. Only hex and rgb(a) colors are supported.
// provideDocumentColors (browser)
(async () => {
const lsp = new wikiparse.LanguageService(),
wikitext = `
<p style="color: rgba(255, 0, 0, .7)">
<poem style="color: #00ff00ff"/>
{{#tag:font|color=#f000}}
{{color|rgb(0 0 255 / 50%)}}
`;
assert.deepStrictEqual(
await lsp.provideDocumentColors(wikitext),
[
{
range: {
start: {line: 1, character: 17},
end: {line: 1, character: 36},
},
color: {red: 1, green: 0, blue: 0, alpha: 0.7},
},
{
range: {
start: {line: 2, character: 20},
end: {line: 2, character: 29},
},
color: {red: 0, green: 1, blue: 0, alpha: 1},
},
{
range: {
start: {line: 3, character: 18},
end: {line: 3, character: 23},
},
color: {red: 1, green: 0, blue: 0, alpha: 0},
},
{
range: {
start: {line: 4, character: 8},
end: {line: 4, character: 26},
},
color: {red: 0, green: 0, blue: 1, alpha: 0.5},
},
],
);
})();
Expand
param: ColorPresentationParams
returns: Promise<ColorPresentation[]>
Obtain a list of presentations for a color value at a given location.
// provideColorPresentations (browser)
(async () => {
const lsp = new wikiparse.LanguageService({}),
range = {
start: {line: 0, character: 0},
end: {line: 0, character: 1},
};
assert.deepStrictEqual(
await lsp.provideColorPresentations({
color: {red: 1, green: 0, blue: 0, alpha: 0.5},
range,
}),
[
{
label: '#ff000080',
textEdit: {range, newText: '#ff000080'},
},
],
);
assert.deepStrictEqual(
await lsp.provideColorPresentations({
color: {red: 0, green: 0.9, blue: 0, alpha: 1},
range,
}),
[
{
label: '#00e600',
textEdit: {range, newText: '#00e600'},
},
],
);
})();
对维基文本批量执行语法检查的命令行工具
用于维基文本的 VSCode 扩展
A command-line tool that performs linting on Wikitext in bulk
VSCode extension for Wikitext