Extension:Wiki2LaTeX

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Wiki2LaTeX

Release status: beta

Implementation Tag, User interface, Data extraction
Description Exports Mediawiki-articles to LaTeX and PDF
Author(s) Hans-Georg Kluge (HG Talk)
Version 0.7 (2007-10-11)
MediaWiki 1.11
Download Google Code Projectsite
readme
Hooks used

SkinTemplateContentActions
UnknownAction
BeforePageDisplay
LoadAllMessages


Contents

[edit] News

[edit] Extension is still alive

In the last few months I have been too busy with some university stuff so I wasn't able to put much time into developing this extension. But as I use my extension on a daily basis I did find some bugs and fixed them so there will be a bugfix-release soon. This version will not yet be tested with Mediawiki 1.12, which introduced big changes to the code of the parser.

In other news the Wikimedia Foundation stated that they have started a project which aims to bring pdf-export to all the Mediawikis by introducing an extension called Collections. The few tests I made some weeks ago looked promising and my guess is, that it will be a good and simple way for any user to get a pdf-version of an article. Still Wiki2LaTeX offers some ways of customizing the output (f.e. templates) and it does offer any possibility which LaTeX itself offers. So I will not abandon Wiki2LaTeX in favor to Collections.

Last but not least I want to state some future ideas and plans:

  • Add support for some syntax-features like interwiki links.
  • Revisit the parsing order and fix remaining problems regarding template expansion.
  • Address some security issues; especially temporary files.
  • Remove the pdf-archive and put it into an own extension.
  • Remove GeSHi as it was interesting to look at the code this way when W2L did not work completely reliable. This has changed now so syntax-Highlighting doesn't seem to be necessary anymore (I haven't used it in months).
  • Simplify the UI.

Any suggestions and comments on these plans are welcome.

--HG 15:11, 24 March 2008 (UTC)

Older news


[edit] What can this extension do?

This extension converts Mediawikisyntax into LaTeX-code, and makes the result available as:

  • A textarea, where the code can be copied from
  • A .tex-file
  • A .pdf-file

The extension is written in php and uses its own parser, which is based on the original one of Mediawiki.

Since the parser supports Parser Extension Tags, this extension enables Mediawiki to be used as a tool to create nicely printable documents. The parser also comes with a eventsystem, so you can hook in a function, which changes the current parser-result.

Example: By default, references created by the "<ref>"-tag are transformed into the latex-command "\footnote{}". In case you use another command for footnotes (like endnotes, or you need some modifications to \footnote), you can hook in a function to the event "W2L_FINISH", which replaces "\footnotes{" by "\endnotes{". Have a look at w2lConfig.php where an example can be found.

[edit] Supported Syntax features

  • ParserFunctions are supported (tested for 'if' and 'switch' only!)
  • ParserExtension-tags are supported.
  • Lists, even nested ones
  • italic and bold font-styles are supported
  • Internal and external links
  • Special characters are masked to LaTeX-commands
  • Some HTML-entities are parsed into their LaTeX-equivalents
  • The nowiki-tag is supported
  • Mediawikis Template-system can be used (with named and unnamed template parameters).
  • Tables

Please note, that even though it is supported, it can't be guaranteed, that everything works flawlessly. Not every possible case has been tested, so please report errors, in case something went wrong.

[edit] Limitations

There are some limitations:

  • The extension sometimes assumes german localization. This will be fixed in later versions.
  • Definition lists are parsed into HTML
  • Only external links are inserted into "url"-commands. Internal links are parsed to text.
  • pdf-export requires much cpu-power. So it can't be recommended, to empower users to personally export an article to pdf.
  • All parts are tested on Windows XP and Ubuntu 7.04 only.

Please be aware, that this extension is still in its beta-phase. There might be security issues, performance issues and any thinkable issue could come up. So this extension is not (yet) intended to be used on a public wiki, though it works as expected for quite a time now on my personal server to create documents for university and letters.

[edit] Planned features

  • Fix some issues regarding templates
  • Support interwiki links
  • Support definition lists
  • Support custom Magicword-variables
  • Find a way to parse articles, which are hosted by another wiki (far away!)
  • Add the ability to edit the latex-code before compiling it
  • Add the possibility to generate links from internal links
  • Support custom image LaTeX code
  • Support some HTML-Tags (like center, b, i, strong, em, tt...)
  • Support special classes on div and span tags

[edit] Documentation

Soon more a detailed documentationpage will be available.

[edit] Usage

After installation, there is a link next to the edit tab, which is labeled as "LaTeX". Click on it, choose some options and export the article.

[edit] Parser Extension Tags

This extension also adds some tags, which are useful for creating wikipages, which are intended for LaTeX-export specifically, like papers for university, letters...

These are the tags:

<noindent/>

No use for wiki, but prevents the paragraph indent of LaTeX.

<newpage/>

Makes LaTeX creating a new page. Does nothing in wiki-mode.

<label>name-of-label</label>
<chapref>name-of-label</chapref>
<pageref>name-of-label</pageref>

These three tags enable LaTeX referencing feature. In wiki mode they return pseudo-values, so you can see, that there are references.

<rawtex>text</rawtex>

This tag can contain pure LaTeX-code, which is syntax-highlighted in wiki mode, and inserted as-is in latex-mode.

[edit] Installation

Please have look at the wiki on the project site, where you can find some documentation.

  1. unpack all files of the archive into the folder '/extensions/w2l'.
  2. Check, if the subfolders 'tmp' and 'archive' exist. If not, please create them and make them writable by your webserver.
  3. Have a look at the file w2lDefaultConfig.php, as some settings might need changes. Place your changes into the file w2lConfig.sample.php
  4. Rename w2lConfig.sample.php to w2lConfig.php
  5. Create the custom namespace LaTeX (optional, but required in order to use LaTeX-Templates and more personalized PDF-Creation).
  6. Make the changes to LocalSettings.php as described below.
  7. In order to use the pdf-export-feature, check out the LaTeX-Template-Documentation over at the project page. Additionally, the folder extensions/w2l/tmp/ has to be writable by the server.

[edit] Changes to LocalSettings.php

Just add the following lines to Localsettings.php:

require_once($IP."/extensions/w2l/wiki2latex.php");

If you are using an extension, which makes use of the syntaxhighlighter GeSHi, this extension has to be loaded before W2L.

If you are using Parser function extensions, then this extension needs to be loaded before W2L.

[edit] Update existing installations

  1. Read Release Notes as config changes might be required.
  2. Backup all files
  3. Remove all files except w2lConfig.php
  4. Unpack all new files into that folder

[edit] See also

The download section on the projectpage contains an example output of this very page you are reading. This pdf was created without the template which is used on this page as tables are not supported yet.

[edit] Development

Development takes place on a subpage.

Personal tools