The CodeMirror extension provides syntax highlighting in MediaWiki wikitext editors using the CodeMirror library.
Extension homepage: https://www.mediawiki.org/wiki/Extension:CodeMirror
JS documentation: https://doc.wikimedia.org/CodeMirror
Development
Preface
Extension:CodeMirror is currently in the process of being upgraded to the new major version, CodeMirror 6. See the change log for details.
Use of CodeMirror 6 is controlled by the wgCodeMirrorV6 configuration setting, or by
passing in cm6enable=1 in the URL query string.
CodeMirror 6 requires the use of NPM to bundle the dependencies. These are built using
Rollup and packaged as ResourceLoader-compatible modules under lib/.
If you make changes to the versions of @codemirror or @lezer packages,
you will need to run npm run build to update the ResourceLoader modules.
NPM commands
NOTE: Consider using Fresh to run these tasks.
npm installto install dependencies.npm run docto generate the API documentation.npm testto run the linting tools, JavaScript unit tests, and build checks.npm run test:lintfor linting of JS/LESS/CSS.npm run test:lint:jsfor linting of just JavaScript.npm run test:lint:stylesfor linting of just Less/CSS.npm run test:i18nfor linting of i18n messages with banana-checker.npm run test:unitfor the new Jest unit tests.npm run selenium-testfor the Selenium tests.npm run update-parser-teststo update the Jest parser tests intests/jest/parser/tests.jsonafter making changes to the MediaWiki Stream parser.npm run buildto rebundle the CodeMirror library. If changes are made to the@codemirroror@lezerdependencies in package.json, this command must be run before sending the patch or CI will fail. This also calls thebuild:eslint,build:stylelint, andbuild:luacheckcommands.npm run build:eslintto rebundle the ESLint library. If changes are made to the@bhsd/eslint-browserifydependency in package.json or the JavaScript worker, this command must be run before sending the patch.npm run build:stylelintto rebundle the Stylelint library. If changes are made to the@bhsd/stylelint-browserifydependency in package.json or the CSS worker, this command must be run before sending the patch.npm run build:luacheckto rebundle the LuaCheck library. If changes are made to theluacheck-browserifydependency in package.json or the Lua worker, this command must be run before sending the patch.npm run build:wikilintto rebundle the WikiParser-Node library. If changes are made to thewikiparser-nodedependency in package.json or the MediaWiki worker, this command must be run before sending the patch.- Older QUnit tests are in
resources/mode/mediawiki/tests/qunit/. These have been replaced and will be removed after the CodeMirror 6 upgrade is complete.