Skip to content

bhsd-harry/monaco-wiki

Repository files navigation

Monaco-Wiki

npm version CodeQL codebeat badge

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.

Usage

You may load the Monaco Editor on your own:

import * as monaco from 'https://cdn.jsdelivr.net/npm/monaco-editor/+esm';
import registerWiki from 'https://cdn.jsdelivr.net/npm/monaco-wiki';

await registerWiki(
	monaco,
	false, // Set to `true` if used in a MediaWiki site
);

or simply:

// Automatically loads the Monaco Editor's core and relevant workers
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 editor

Language Aliases

  • wikitext
  • wiki
  • mediawiki

Themes

Name ID
Monokai monokai
Nord nord

If you wish to use other themes listed here, please submit a feature request.

Known Issues

Syntax Highlighting

  1. Preformatted text with a leading space is not supported.
  2. Bracket pair colorization is imperfect for Wikitext (Example), especially for 4 consecutive braces (Examples 1, 2).
  3. Not error-tolerant (Example).
  4. Interaction between table cells and <nowiki> (Example).
  5. Disallowed HTML tags (Example).
  6. Multiline template names (Example) and link targets (Example).
  7. Template names containing comments (Examples 1, 2).
  8. Template parameter names containing newlines or comments (Example).
  9. Wikitext in template parameter names (Example).
  10. HTML tag breaking template syntax (Examples 1, 2).
  11. Bracket pair inside link text (Example).
  12. Double URI encoding in link targets (Example).
  13. Double HTML escaping in link targets (Example).
  14. Nested internal link in internal/external links (Examples 1, 2).
  15. Interaction between external links and template parameters (Example).

License

GNU General Public License 3.0