I think I've seen a script for converting mediawiki syntax to Latex. Also, in case there are more than one solution for this, it might be nice to summarize them here.

up vote 14 down vote accepted

I'm surprised no one has mentioned Pandoc yet. Quoting its website:

Pandoc can convert documents in markdown, reStructuredText, textile, HTML, DocBook, LaTeX, MediaWiki markup, TWiki markup, OPML, Emacs Org-Mode, Txt2Tags, Microsoft Word docx, LibreOffice ODT, EPUB, or Haddock markup to

  • HTML formats: XHTML, HTML5, and HTML slide shows using Slidy, reveal.js, Slideous, S5, or DZSlides.
  • Word processor formats: Microsoft Word docx, OpenOffice/LibreOffice ODT, OpenDocument XML
  • Ebooks: EPUB version 2 or 3, FictionBook2
  • Documentation formats: DocBook, GNU TexInfo, Groff man pages, Haddock markup
  • Page layout formats: InDesign ICML
  • Outline formats: OPML
  • TeX formats: LaTeX, ConTeXt, LaTeX Beamer slides
  • PDF via LaTeX
  • Lightweight markup formats: Markdown (including CommonMark), reStructuredText, AsciiDoc, MediaWiki markup, DokuWiki markup, Emacs Org-Mode, Textile

It's a command-line tool. Usage:

pandoc input.txt -f mediawiki -t latex --standalone -o output.tex
  • I added this as the correct answer, as it seems to be the most up to date and portable solution, as of 2016. – Samuel Lampa May 30 '16 at 12:38
  • How about the mathematical formulas? For example, I would like to extract the Spearman's Correlation coefficient formula to a LaTeX file so that I do not have to type it in Latex manually. en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient – Ahmedov Aug 18 '16 at 15:13
  • 1
    @Ahmedov, that works fine. :<math>r_s = \rho_{\operatorname{rg}_X,\operatorname{rg}_Y} = \frac {\operatorname{cov}(\operatorname{rg}_X,\operatorname{rg}_Y)} { \sigma_{\operatorname{rg}_X} \sigma_{\operatorname{rg}_Y} }</math> becomes \[r_s = \rho_{\operatorname{rg}_X,\operatorname{rg}_Y} = \frac {\operatorname{cov}(\operatorname{rg}_X,\operatorname{rg}_Y)} { \sigma_{\operatorname{rg}_X} \sigma_{\operatorname{rg}_Y} }\]. In other words, there's not a whole lot of conversion going on in the formulas. – Joe Corneli Oct 16 '16 at 22:52

If you're working from within a MediaWiki, there is the wiki2latex extension.

The software doing that is licensed freely under GPL and can be obtained from:

http://de.wikibooks.org/wiki/Benutzer:Dirk_Huenniger/wb2pdf

You may download the binary for Windows from there too.

On Ubuntu 16.04 or higher it is

sudo apt-get install mediawiki2latex

and then call the program by, for instance,

mediawiki2latex -u https://en.wikipedia.org/wiki/Adam_Ries -o AdamRies.pdf

Zim is WYSIWYG desktop note-taking application with a wiki markup that can directly export their .txt pages to HTML or LaTeX code. It is available for Windows, BSD and Linux (included in several distributions). It can export single pages or complete notebooks.

A simple page of Zim, their internal wiki code and the compiled LaTeX export as article is showed below:

MWEzim

Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-10-05T19:09:32+02:00

====== Testing Zim ======

===== Title 2 =====

==== Title 3 ====

=== Title 4 ===

== Title 5 ==

Some text  normal **bold** //italic// __underlined__
~~deleted~~ normal ''literal ''_{ sub} ^{super}

* item
* item
* item

[*] item checked
[ ] item not checked

MWELatex

  • 1
    Unfortunately it doesn't use MediaWiki mark up, but its own format – Alexey Grigorev Dec 29 '13 at 14:43
  • @AlexeyGrigorev, Yes, but for simple pages can be useful. If you simply make a search & replace from ''' to ** and from '' to // (in that order, obviously) you can later import the MediaWiki code with bolds and italics working, and the titles, the [[links]] and the itemized list are imported without modification. – Fran Dec 30 '13 at 11:13

This perl script seems to be the script I was thinking of.

  • 2
    It says: "Update: Don't use this. Use Pandoc instead!" – Erel Segal-Halevi Aug 28 '15 at 14:22

Javalatex seems like a very interesting project, and should have support for this. (Haven't tried them yet, but will report experience when I have)

There is also WikiPublisher addon which is built specifically as an addon to pmwiki. I have been using it with quite some success.

There is a web solution based on pandoc mentioned in other answers.

https://devotter.com/converter

I haven't had a chance to test these out, but these three look most promising:

  1. Pandoc (Web interface)

    In Ubuntu:

    sudo apt-get install pandoc
    pandoc --standalone -f mediawiki -o output.tex input.txt
    
  2. Dirk Hünniger. MediaWiki to LaTeX (Web interface)

    In Ubuntu:

    sudo apt-get install mediawiki2latex
    mediawiki2latex -u https://en.wikipedia.org/wiki/Adam_Ries -o AdamRies.pdf
    

    As a special-purpose tool, this might have better features than the others, but it requires a full TexLive installation (~2.5 Gb)

  3. C. Scott Ananian & Wikimedia Foundation. mw-ocg-latexer.

    This is designed for WikiBooks of bundled wiki pages, so it probably isn't as easy to use as the first two.

I found the following projects as well, but they are unmaintained, so I don't recommend trying them unless you know what you're doing. The dates indicate when development seems to have stopped.

  1. Szymon Tarnowski, cjiahao, & Hans-Georg Kluge. (2011/2013). Wiki2LaTeX. Server-side. Copied to github here.
  2. cyrilbuttay, jucablues, pajai, swalter. (2013). WikiPDF. (Overview of code)
  3. Derbeth, Sergei Turin, & tuetschek (2010). javaLatex.
  4. Daniel O'Connor. (2010). Text_Wiki.
  5. Chris Wellons. (2007). wiki2latex.perl. Author now recommends Pandoc.

I did a very thorough internet search, so I believe that this is comprehensive of all software on the internet to convert MediaWiki markup to LaTex.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.