monaco-wiki
v2.1.0
Published
Monaco editor for MediaWiki sites
Downloads
822
Readme
Monaco-Wiki
Monaco-Wiki registers the Wikitext language in the Monaco Editor. It is a web version of the Visual Studio Code extensions developed by Rowe Wilson Frederisk Holme and Bhsd. The TextMate grammar is substantially revised to be site-specific and more accurate.
Installation
npm install monaco-wikiUsage
You may load the Monaco Editor and prepare the bundle on your own:
import * as monaco from 'https://cdn.jsdelivr.net/npm/monaco-editor/+esm';
import light from 'shiki/themes/github-light.mjs';
import registerWiki, {
registerJavaScript,
registerCSS,
registerLua,
registerVue,
} from 'monaco-wiki';
await registerWiki(
monaco,
// Set to `true` if used in a MediaWiki site,
// or a string to specify a preset configuration (https://github.com/bhsd-harry/wikiparser-node/tree/main/config)
false,
// (optional) i18n language codes with a preferred order,
// e.g. `['zh-hans', 'zh-hant', 'en']
['en'],
// (optional) custom download URL for the `wikiparse` object`
'https://cdn.jsdelivr.net/npm/wikiparser-node',
// (optional) Shiki themes
[light],
// (optional) WikiLint options
{
// `0` ignores all, `1` ignores warnings, `2` reports all (default)
defaultSeverity: 1,
// Rules are listed at https://github.com/bhsd-harry/wikiparser-node/wiki/Rules
'no-arg': 0,
},
);
registerJavaScript(
monaco,
// (optional) custom download URL for the `eslint` object`
'https://cdn.jsdelivr.net/npm/@bhsd/eslint-browserify',
// (optional) ESLint options
// See https://eslint.org/docs/v8.x/use/configure/
{
parserOptions: {
sourceType: 'module',
},
},
);
registerCSS(
monaco,
// (optional) custom download URL for the `stylelint` object`
'https://cdn.jsdelivr.net/npm/@bhsd/stylelint-browserify',
// (optional) Stylelint options
// See https://stylelint.io/user-guide/configure/
{
rules: {
'length-zero-no-unit': true,
},
},
);
registerLua(
monaco,
// (optional) custom download URL for the `luacheck` object`
'https://cdn.jsdelivr.net/npm/luacheck-browserify',
// (optional) Luacheck options
// See https://luacheck.readthedocs.io/en/stable/config.html#config-options
{
std: 'mediawiki',
},
);
await registerVue(
monaco,
// (optional) Shiki themes
[light],
);or simply load the pre-bundled version from a CDN:
// Optionally specify the jsDelivr CDN, defaulting to https://fastly.jsdelivr.net
window.monaco = {CDN: 'https://cdn.jsdelivr.net'};
// Automatically loads the Monaco Editor's core and relevant workers
await import('https://cdn.jsdelivr.net/npm/monaco-wiki/dist/all.min.js');
await monaco; // The global `monaco` is a promise that resolves to the Monaco editorLanguage Aliases
- wikitext
- wiki
- mediawiki
Bundled Themes
|Name|ID|
|:-:|:-:|
|Light+|light-plus|
|Monokai|monokai|
Known Issues
Syntax Highlighting
Redirect
- Redirect is only allowed at the beginning of a page (Example).
Extension
- Legacy syntax of
<tvar>tags is not supported (Example). <gallery>tags are not supported (Example).- Nested language in
<syntaxhighlight>(Example). <nowiki>tags inside<pre>are not supported (Example).- Multiline extension tags (Example).
- Extension tags containing unclosed comments (Example).
- Extension tags cannot be nested in same tags (Example).
Transclusion
- Bracket pair colorization is problematic (Example), especially for 4 consecutive braces (left or right braces).
- Substitution is not correctly highlighted (Example).
- Non-existing parser functions starting with
#are highlighted as parser functions (Example). - Multiline template names should be invalid (Example).
- Template names containing comments are not highlighted (Example).
- Template parameter names containing newlines or comments are not highlighted (Example).
- HTML tags break the template syntax (Example).
- External links break the template syntax (Example).
- Parameter names of
#invokeare not highlighted (Example). - Conflict between transclusion and language conversion syntax (Example).
Heading
- Multiline trailing comments break section headings (Example).
- Section headings containing multiline extension tags are not highlighted (Example).
HTML tag
- Complex HTML tag attributes are not supported (comments,
<noinclude>/<includeonly>, templates or HTML tags). - HTML tag attributes cannot contain
>(Example). - Disallowed HTML attributes should not be highlighted (Example).
Table
- Interaction between table cells and
<nowiki>is highlighted incorrectly (Example). - Interaction between table cells and templates is highlighted incorrectly (Example).
- Interaction between table cells and HTML tags is highlighted incorrectly (Example).
- Interaction between table cells and comments is highlighted incorrectly (Example).
- Complex table attributes are not supported (Example).
- Comments at the SOL break table syntax (Example).
||/!!after templates are not highlighted (Example).
Link
- Multiline link targets should be invalid (Example).
- A bracket pair inside link text is highlighted incorrectly (Example).
- Link targets with templates may be highlighted incorrectly (Example).
- Lonely
[[breaks highlighting (Example).
Apostrophe
- Mixing bold and italic apostrophes (Example).
External link
- External links are not XML tags (Example).
- External links cannot be nested in links (Example).
- Magic links cannot be nested in links (Example).
Block element
- Preformatted text with a leading space is not supported.
- One-line definition lists are not supported (Example).
- Comments at the SOL break the highlighting (Example).
Language conversion
- BCP 47 language codes are not supported in language conversion (Example).
