Tuesday, July 19, 2011

How to post mathematics in wikipedia or in MediaWiki? the MediaWiki API and extensions

How to write mathematics in blog/sites (not wiki)?
See this post:
http://ex-ample.blogspot.com/2011/07/mathml-chromefirefox-and-best.html

An ex-ample : the online  NIST Digital Library of Mathematical Functions {Abramowitz and Stegun’s (1964) Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables}.
http://ex-ample.blogspot.com/2011/07/best-ex-ample-nist-digital-library-of.html

The first steps for writing/test your equation/formula in wikipedia:
------------
The operation of Wikipedia depends on MediaWiki, a custom-made, free and open source wiki software platform written in PHP and built upon the MySQL database. If you want to compare wiki: http://www.wikimatrix.org/
http://en.wikipedia.org/wiki/Comparison_of_wiki_software
------------

MediaWiki has 3 interfaces (http://www.mediawiki.org/wiki/API):
• the MediaWiki API, which provides convenient access to wiki features, data and meta-data.
• the Special:Export page, which provides bulk export of wiki content as XML. Read the Export help article on meta.mediawiki.org for more information.
• the standard web-based interface.
Extensions:
---version of mediaWiki used by wikipedia:
http://en.wikipedia.org/wiki/Special:Version#Installed_extensions

---inserting unusual characters:
http://www.mediawiki.org/wiki/Extension:CharInsert allows creation of JavaScript box for inserting unusual characters.
or copy/paste from: http://en.wikipedia.org/wiki/MediaWiki:Edittools

---mathematics, formula, equations:
Mediawiki des not have an integrated equation editor.
It only has a LaTeX rendering: you have to write or copy/paste a latex code  between HTML math-tags.
Then it's painful if you want to write pages on Math with a LARGE number of math equations (and symbols, graphs...), easily.

Mediawiki and MathML and LaTeX:

http://en.wikipedia.org/wiki/Help:Displaying_a_formula

http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style_(mathematics)#Typesetting_of_mathematical_formulae

MediaWiki uses a subset of (AMS-LaTeX markup
(http://en.wikipedia.org/wiki/AMS-LaTeX; http://www.ams.org/publications/authors/tex/amslatex),
a superset of LaTeX markup which is in turn a superset of TeX markup.
It generates either PNG images or simple HTML markup, depending on user preferences (see below).

Technical notes on AMS-LaTeX:
ftp://ftp.ams.org/pub/tex/amslatex/math/technote.pdf

http://en.wikipedia.org/wiki/Texvc
The program texvc (TeX validator and converter) validates AMS-LaTeX mathematical expressions and converts them to HTML, (limited MathML), or PNG graphics.

MediaWiki uses texvc to render mathematical formulas and similar content. The aim is to allow a single syntax for math markup while allowing a range of output formats to be generated, and to provide protection against cross-site scripting and other potential security issues. In addition, texvc provides some extensions to standard AMSLaTeX, such as \codes for HTML math character entities (for example, Σ → \Sigma) which have different names in LaTeX.

The HTML-code generated by texvc is based on 3 classes.
• Conservative: the code should look good and work well in most browsers.
• Moderate: the code should work and look good in reasonably modern browsers.
• Liberal: the code is HTML, but it is designed for very recent browsers, such as newer versions of Mozilla. While it should be legible, it might not look very good.

There is also limited support for exporting to MathML.
Texvc is written in OCaml, along with PHP code to integrate it with the rest of MediaWiki.
It uses dvipng (instead of the commonly used combination of ImageMagick and dvips) to convert LaTeX's output to PNG files.
Like the rest of MediaWiki, it is available under the terms of the GNU GPL from the MediaWiki site.
Texvc cannot render arbitrary Unicode characters.

Rendering of this solution and the alt text (http://en.wikipedia.org/wiki/Wikipedia:ALT)
• The PNG images are black on white (not transparent).
• The alt text of the PNG images, which is displayed to visually impaired and other readers who cannot see the images, and is also used when the text is selected and copied.

Blahtex

The choice of wikipedia-mediawiki is clear: Latex AND conversion to MathML.
TeX is more display-oriented and MathML is more semantics-oriented, then we need both.
In the future, mediawiki will be able to generate enhanced HTML and MathML in many cases.
http://www.mediawiki.org/wiki/Blahtex
Blahtex is a TeX-to-MathML converter intended for use with MediaWiki. It also outputs PNG graphics, much as the current TeX implementation on Wikipedia does.
http://www.mediawiki.org/wiki/Extension:Blahtex/Embedding_Blahtex_in_MediaWiki

http://gva.noekeon.org/blahtexml/
http://gva.noekeon.org/blahtexml/blahtexml-0.9-doc.pdf
http://developer.berlios.de/projects/blahtex/

Suggested structure of a mathematics article in wikipedia:
http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style_(mathematics)#Typesetting_of_mathematical_formulae

for Proofs
Wikipedia is an encyclopedia, not a collection of mathematical texts; but we often want to include proofs:
http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Mathematics/Proofs

for Algorithms
There are no universally accepted standards for presenting algorithms on Wikipedia.
Source code should always use syntax highlighting.
http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Computer_science/Manual_of_style_(computer_science)#Algorithms

--------------Preferences for Latex rendering:
Go to My Preferences
http://en.wikipedia.org/wiki/Special:Preferences#preftab-1
You have 6 choices:

ProveIt is a user script that makes it really easy to find, edit, add, and cite references in Wikipedia articles. http://en.wikipedia.org/wiki/User:ProveIt_GT
it uses several javascript libs (jQuery UI, loaded via Google Libraries API.)

WikEd is a full-featured Wikipedia-integrated advanced text editor.
http://en.wikipedia.org/wiki/User:Cacycle/wikEd
Pasting, import, and wiki code conversion of formatted text, e.g. from Microsoft-Word and web pages
Check the wikEd help page for a description of all buttons: http://en.wikipedia.org/wiki/User:Cacycle/wikEd_help

No equation editor or chemical formulae editor!!!
It only offers some useful tools:
http://en.wikipedia.org/wiki/User:Cacycle/wikEd_help#Missing_features_and_other_shortcomings
Fix buttons:

• Fixes some common math issues outside of the math wikitag
• Fixes unformatted chemical formulas. Super- and subscripts indices, uppercases elements, and fixes reaction arrows.
• Correct a large number of physical units.
DejaVu fonts

Multimedia
Several new software features have been developed to improve the handling of multimedia in Wikipedia in collaboration with Kaltura (http://corp.kaltura.com/):
• Easy searching and adding of media files to Wikipedia articles
• Simplified uploading of videos and other media files to Wikimedia Commons
• A new video player that is capable of displaying and adding subtitles
• A sequence editor to create a mash up presentation of images and sound
--------------New user information (Guidelines, help, resources):
http://en.wikipedia.org/wiki/Wikipedia:Community_portal

--------------Tools
http://en.wikipedia.org/wiki/Wikipedia:Tools

LaTeX to Wikicode is a web-based translator.
LaTeX2wiki converts sections, math, and references using a web form:
http://en.wikipedia.org/wiki/User:Jmath666/latex2wiki

Wikipedia supports syntax highlighting. For information on how to use it, and the languages supported, see Syntax Highlight Extension: http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi

http://en.wikipedia.org/wiki/Wikipedia:Text_editor_support
Text on Wikipedia is encoded using the UTF-8 character set, which allows the use of many non-English characters and special symbols.
• Many external editors
• In-browser editors: wikEd

http://en.wikipedia.org/wiki/Wikipedia:Tools/Browser_tools/Mozilla_Firefox:

--------------music symbols and TeX:
http://meta.wikimedia.org/wiki/Music_markup