User:MjolnirPants/mediawiki lang npp

From Wikipedia, the free encyclopedia
This is what the formatting looks like in Notepad++

I have found it useful to be able to edit wikipedia outside of wikipedia itself. Rather than opening a second tab or window with my sandbox in it, I've taken to editing in Notepad++. This has the advantage of giving me the entire width of my screen for editing, as well as providing a storage place from which I can easily cut and paste. This page hosts the UDL (User Defined Language) .xml file I use for this purpose. I've included a screen shot to show the formatting it creates.

If you have any suggestions or comments, feel free to let me know here or on my user talk page. I've found this very useful, and I hope someone else does, too.

Notes, features & limitations[edit]

  • This UDL does not allow folding of code (meaning you cannot collapse sections).
  • It does not recognize keywords such as template or article names, and so it will not warn you if you typo something.
  • It will 'bleed' formatting past a tag if you forget to close it out.
  • It doesn't recognized nested tags, so it will not format a wikilink within a template, for instance.
  • There is currently no way to preview in Notepad++.
  • There is currently no way to implement additional text styles (right now there are 8, some of which are used for multiple markups.)

Code[edit]

MediaWiki.xml — Expand to see the code.
<NotepadPlus>
    <UserLang name="MediaWiki" ext="wiki" udlVersion="2.1">
        <Settings>
            <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
            <Prefix Keywords1="yes" Keywords2="yes" Keywords3="yes" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Comments">00 01 02 03&lt;! 04--&gt;</Keywords>
            <Keywords name="Numbers, prefix1"></Keywords>
            <Keywords name="Numbers, prefix2"></Keywords>
            <Keywords name="Numbers, extras1"></Keywords>
            <Keywords name="Numbers, extras2"></Keywords>
            <Keywords name="Numbers, suffix1"></Keywords>
            <Keywords name="Numbers, suffix2"></Keywords>
            <Keywords name="Numbers, range"></Keywords>
            <Keywords name="Operators1">/</Keywords>
            <Keywords name="Operators2"></Keywords>
            <Keywords name="Folders in code1, open">&lt;fold&gt;</Keywords>
            <Keywords name="Folders in code1, middle"></Keywords>
            <Keywords name="Folders in code1, close">&lt;/fold&gt;</Keywords>
            <Keywords name="Folders in code2, open"></Keywords>
            <Keywords name="Folders in code2, middle"></Keywords>
            <Keywords name="Folders in code2, close"></Keywords>
            <Keywords name="Folders in comment, open"></Keywords>
            <Keywords name="Folders in comment, middle"></Keywords>
            <Keywords name="Folders in comment, close"></Keywords>
            <Keywords name="Keywords1">&apos;&apos;&apos;</Keywords>
            <Keywords name="Keywords2">&apos;&apos;</Keywords>
            <Keywords name="Keywords3">*</Keywords>
            <Keywords name="Keywords4"></Keywords>
            <Keywords name="Keywords5"></Keywords>
            <Keywords name="Keywords6"></Keywords>
            <Keywords name="Keywords7"></Keywords>
            <Keywords name="Keywords8"></Keywords>
            <Keywords name="Delimiters">00(( [[ &lt;ref&gt; )) 01 02(( ]] &lt;/ref&gt; )) 03(( &apos;&apos;&apos;&apos;&apos; [ )) 04 05(( &apos;&apos;&apos;&apos;&apos; ] )) 06{{ 07 08}} 09(( &apos;&apos;&apos; ==== ===== ====== )) 10 11(( &apos;&apos;&apos; ==== ===== ====== )) 12&apos;&apos; 13 14&apos;&apos; 15&lt; 16 17&gt; 18=== 19 20=== 21== 22 23==</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="Arial" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="COMMENTS" fgColor="408080" bgColor="FFFF80" fontName="Courier New" fontStyle="0" nesting="0" />
            <WordsStyle name="LINE COMMENTS" fgColor="000000" bgColor="FFFFFF" fontName="Georgia" fontStyle="1" nesting="0" />
            <WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="2" nesting="0" />
            <WordsStyle name="KEYWORDS3" fgColor="FF80FF" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS4" fgColor="808040" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="OPERATORS" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS1" fgColor="0000FF" bgColor="FFFFFF" fontName="Arial" fontStyle="1" nesting="0" />
            <WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="FFFFFF" fontName="Arial" fontStyle="3" nesting="0" />
            <WordsStyle name="DELIMITERS3" fgColor="800080" bgColor="FFFFFF" fontName="Arial" fontStyle="1" nesting="0" />
            <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="Arial" fontStyle="1" nesting="0" />
            <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontName="Arial" fontStyle="2" nesting="0" />
            <WordsStyle name="DELIMITERS6" fgColor="FF0080" bgColor="FFFFFF" fontName="Arial" fontStyle="1" nesting="0" />
            <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="Georgia" fontStyle="1" nesting="0" />
            <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="Georgia" fontStyle="3" fontSize="12" nesting="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

Instructions[edit]

Installation[edit]

If you don't have it already, please download and install Notepad++. Don't worry, it's free and open-source. Once that's done, follow these steps.

  1. Open notepad (or Notepad++) and copy the code above into it.
  2. Save the file with whatever name you like, with the extension .xml. Make sure the Save as type: drop-down is set to All files (*.*) before you save. (If you use Notepad++ to save it, you can choose XML from that dropdown, instead of typing in the extension yourself.)
  3. Open Notepad++ and create a new document.
  4. Type some mediaWiki code into it. (Give it a section or two, add some wikilinks and comments and so on.)
  5. Save the document as whatever name you like, with the file extension .wiki. Make sure that the Save as type: drop down list is set to All types (*.*).
  6. Click on Language in the menu bar and select Define your language... from the drop-down.
  7. In the window that opens up, select the Import... button at the top.
  8. Browse to the location you saved the .xml file to and select it.
  9. If the text in your .wiki file hasn't changed formatting, click on the Language menu item again. This time, you should notice MediaWiki at the bottom of the list, below Define your language.... Select it.
  10. Enjoy your offline editing!

File Association[edit]

As an optional step, if you are using Windows you can also set Notepad++ to open .wiki files by default. To do this, complete the following steps:

  • Browse to the .wiki file you saved and double click on it.
  • When the dialog box stating that Windows can't open the file appears, choose Select a program from a list of installed programs and click OK.
  • In the next window, make sure that Always use the selected program to open this kind of file is checked at the bottom, and either find Notepad++ in the list of programs shown, or click Browse... and browse to the folder that contains it.
  • Click OK as many times as needed to close the boxes, and watch it open in Notepad++.

Linux Users[edit]

If you are a Linux user, you can still download Notepad++ and use this UDL. Just apt-get Wine and make sure it is installed and working properly before downloading and installing Notepad++. Once this is done, follow the steps above for installation. If you use Ubuntu, Wine is available on the Ubuntu Software Center (at least it was the last time I checked).

Mac Users[edit]

If you are a Mac user, please do yourself a favor and get a computer that isn't designed to be the blackest box on the market. Just kidding! There is plenty of compatibility layer software designed to allow you to run Windows applications on your Mac. Unfortunately, few of them are free, so I'm not going to suggest one here.

See Also[edit]

External links[edit]

Category:Wiki software
Category:Free wiki software