Subhadip's Blog

My experience with the computing world!

How to easily write in MediaWiki

MediaWiki is a very popular free and open-source wiki software that powers some of the most visited wikis on the Internet including the Wikipedia. You can also host it in your own environment for your own wiki requirements or for your organization.

At my work, we use MediaWiki for our developer's wiki site. When I started working for a new product team sometimes back, I came to know about this wiki format for the first time and I didn't like it very much.

I usually like to contribute to the wikis more often than not but when I first went on to add my first page to this wiki, I noticed a few annoying things:

Then I turned towards the Internet looking for a solution. The first thing that came to my mind was to use a WYSIWYG editor that generates output in MediaWiki format instead of HTML But the thought of using a web based editor was repulsion enough for me to drive myself towards looking for a better solution.

Then I came to know about this wonderful command line utility called pandoc that can magically convert virtually any text format into another including markdown to mediawiki. This solution had at least two benefits:

  1. I was already fond of using markdown. So no learning curve for me.
  2. I could use Vim! If you know how to use Vim, you'd know that there's no other editor that can make you more productive. And also Vim supports syntax highlighting for markdown out of the box.

Converting a markdown file to mediawiki is as simple as the below command:

pandoc -f markdown -t mediawiki -o sample_wiki.mediawiki sample_wiki.markdown

Although initially I had to go through the markdown documentation page for pandoc to learn a few tricks to ensure that my markdown texts get converted to mediawiki the way I want it to but after a day or two, it felt painless. And the best thing is that you can convert between these two text formats both ways without any distortion.


Click here to load the comments. By clicking you agree to the Disqus privacy policy.