From dfb4281a148a5cef1027fad425fb3aa0ff01e928 Mon Sep 17 00:00:00 2001
From: Dawa Ometto MediaWiki headers are written with different indentation using To display text as bold, wrap the text in Use HTML special characters, e.g. MediaWiki ignores single line breaks. To start a new paragraph, leave an empty line. You can force a line break within a paragraph with the HTML tag Tables may be authored in wiki pages using either XHTML table elements directly, or using wikicode formatting to define the table. Wikitable syntax overview: ' +
+'$1$2"
+ },
+
+ 'function-ul' : {
+ exec: function( txt, selText, $field ) {
+ var repText = '';
+ var lines = selText.split("\n");
+ for ( var i = 0; i < lines.length; i++ ) {
+ repText += '* ' + lines[i] + "\n";
+ }
+ repText = repText.substring(0, repText.length-1)
+ $.GollumEditor.replaceSelection( repText, true, true );
+ },
+ },
+
+ 'function-ol' : {
+ exec: function( txt, selText, $field ) {
+ var repText = '';
+ var lines = selText.split("\n");
+ for ( var i = 0; i < lines.length; i++ ) {
+ repText += '# ' + lines[i] + "\n";
+ }
+ repText = repText.substring(0, repText.length-1)
+ $.GollumEditor.replaceSelection( repText, true, true );
+ },
+ },
+
+ 'function-blockquote' : {
+ search: /(.+)([\n]?)/g,
+ replace: "\n$1$2\n
",
+ break_line: true,
+ },
+
+ 'function-h1' : {
+ search: /(.+)([\n]?)/g,
+ replace: "= $1$2 =",
+ break_line: true,
+ whole_line: true
+ },
+
+ 'function-h2' : {
+ search: /(.+)([\n]?)/g,
+ replace: "== $1$2 ==",
+ break_line: true,
+ whole_line: true
+ },
+
+ 'function-h3' : {
+ search: /(.+)([\n]?)/g,
+ replace: "=== $1$2 ===",
+ break_line: true,
+ whole_line: true
+ },
+
+ 'function-link' : {
+ exec: function( txt, selText, $field ) {
+ var results = null;
+ $.GollumEditor.Dialog.init({
+ title: 'Insert Link',
+ fields: [
+ {
+ id: 'text',
+ name: 'Link Text',
+ type: 'text',
+ help: 'The text to display to the user.',
+ defaultValue: selText
+ },
+ {
+ id: 'href',
+ name: 'URL',
+ type: 'text',
+ help: 'The URL to link to.'
+ }
+ ],
+ OK: function( res ) {
+ var h = '';
+ if ( res['text'] && res['href'] ) {
+ h = '[' + res['href'] + ' | ' +
+ res['text'] + ']';
+ }
+ $.GollumEditor.replaceSelection( h );
+ }
+ });
+
+
+ }
+ },
+
+ 'function-critic-accept' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ },
+
+ 'function-critic-reject' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ }
+
+
+};
+
+$.GollumEditor.defineLanguage('mediawiki', MediaWiki);
+
+
+var MediaWikiHelp = [
+ {
+ menuName: 'Text Formatting',
+ content: [
+ {
+ menuName: 'Headers',
+ data: '= Title = (equals sign). MediaWiki supports headings 1-6.'''. To display text as italic, wrap the text in ''. To create monospace text, wrap the text in <code></code>."
+ },
+ {
+ menuName: 'Special Characters',
+ data: '© or €.' +
+'
' +
+'
' +
+'{|table start ' +
+' ' +
+'
|+table caption, optional; only between table start and first table row ' +
+' ' +
+'
|-table row, optional on first row -- wiki engine assumes the first row ' +
+' ' +
+'
!table header cell, optional. Consecutive table header cells may be added on same line separated by double marks ( !!) or start on new lines, each with its own single mark (!). ' +
+' ' +
+'
|table data cell, required! Consecutive table data cells may be added on same line separated by double marks ( ||) or start on new lines, each with its own single mark (|). ' +
+'
|}table end
To create links to external pages, use single brackets, e.g. [https://mediawiki.org MediaWiki]. Internal links use double brackets: [[Main Page]]. To define the link text, use [[Main Page | this is displayed]] (note: the order of the URL/Page Name and the link text is reversed compared to Gollum pages in other markups).
Use Gollum internal links, e.g. [[sauron.jpg]], to insert images.'
+ }
+ ]
+ }
+];
+
+$.GollumEditor.defineHelp('mediawiki', MediaWikiHelp);
+
+})(jQuery);