fix highlighting space behind page name in Templates (v 1.0.1)

* fix code mirror options
* fix code mirror font
* fix code mirror border

Change-Id: I7b8063cd8c5e6450b9cea0f76ed27a8ffb9ae990
This commit is contained in:
Pavel Astakhov 2014-08-21 11:54:15 +06:00
parent c8bd7736f9
commit 67a828cf3e
4 changed files with 20 additions and 9 deletions

View file

@ -15,7 +15,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is an extension to MediaWiki and thus not a valid entry point.' );
}
const CODEMIRROR_VERSION = '1.0.0';
const CODEMIRROR_VERSION = '1.0.1';
// Register this extension on Special:Version
$wgExtensionCredits['parserhook'][] = array(

View file

@ -1,12 +1,12 @@
$( document ).ready( function () {
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("wpTextbox1"), {
mode: "text/mediawiki",
styleActiveLine: true,
lineNumbers: true,
//lineNumbers: true,
lineWrapping: true,
indentUnit: 4,
indentWithTabs: true
//indentUnit: 4,
//indentWithTabs: true
//matchBrackets: true,
//autoCloseBrackets: true
//autoCloseBrackets: true,
mode: "text/mediawiki"
});
} );

View file

@ -3,7 +3,8 @@
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
height: 400px;
border: 1px solid #CCC;
}
.CodeMirror-scroll {
/* Set scrolling behaviour here */

View file

@ -17,12 +17,19 @@ CodeMirror.defineMode("mediawiki", function(config, parserConfig) {
state.tokenize = inParserFunctionName;
return "strong";
}
stream.eatWhile(/[^\|}]/);
stream.eatWhile(/[^\|\}\s]/);
state.tokenize = inTemplateArgumentSeparator;
return "link";
}
function inTemplateArgumentSeparator(stream, state) { // {{ Page name |
if (stream.eatSpace() && !stream.eol()) {
var peek = stream.peek();
if ( peek !== "|" && peek != "}" ) {
state.tokenize = inTemplatePageName;
return "link";
}
}
if (stream.eat("|")) {
state.tokenize = inTemplateArgument;
return "tag strong";
@ -33,9 +40,12 @@ CodeMirror.defineMode("mediawiki", function(config, parserConfig) {
return "tag bracket";
}
}
stream.next();
if ( stream.eol() ) {
return null;
}
stream.next();
return "error";
}
function inTemplateArgument(stream, state) { // {{ Page name |
stream.eatWhile(/[^\|}]/);