mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 10:59:56 +00:00
5cc10a810a
This allows extensions to register their own rules for detecting wikitext, e.g. matching '<ref>'. Bonus: Strip the autogenerated <references/> tag which gets inserted when converting a <ref>. Bug: T128805 Change-Id: I7a38db45d25e86ff3f3f6199aa04425ec98f7cc4
32 lines
761 B
JavaScript
32 lines
761 B
JavaScript
/*!
|
|
* VisualEditor MediaWiki WikitextTransferRegistry and registrations.
|
|
*
|
|
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Heuristic patterns which attempts to discover wikitext, without
|
|
* incurring too many false positives.
|
|
*
|
|
* Rules can be regular expressions or strings
|
|
*/
|
|
ve.ui.mwWikitextTransferRegistry = new OO.Registry();
|
|
|
|
ve.ui.mwWikitextTransferRegistry.register(
|
|
'heading',
|
|
// ==...== on a single line of max 80 characters
|
|
/(^\s*(={2,6})[^=\r\n]{1,80}\2\s*$)/m
|
|
);
|
|
|
|
ve.ui.mwWikitextTransferRegistry.register(
|
|
'link',
|
|
// [[...]] on a single line of max 80 characters
|
|
/\[\[.{1,80}\]\]/m
|
|
);
|
|
|
|
ve.ui.mwWikitextTransferRegistry.register(
|
|
'template',
|
|
'{{'
|
|
);
|