LaTeX to Wikitext Converter
Convert LaTeX markup to MediaWiki wikitext instantly. Handles math, tables, sections, lists, formatting, and environments with accurate transpilation.
About
LaTeX and MediaWiki wikitext are structurally incompatible markup systems. LaTeX uses nested brace-delimited commands (e.g., \frac{a}{b}) while wikitext relies on template syntax and HTML-like constructs. Manual conversion introduces transcription errors in math notation, broken table structures, and lost semantic hierarchy. This tool performs multi-pass transpilation: it strips document preambles, converts sectioning commands (\section → ==...==), transforms list environments into wikitext bullet/numbered syntax, parses tabular environments into wiki pipe-tables, and wraps remaining math in <math> tags for MediaWiki's Texvc renderer. The converter handles approximately 80 common LaTeX commands. It does not interpret custom macros defined via \newcommand or packages beyond the standard set. Documents exceeding ~50,000 characters may require sectional conversion.
Formulas
The converter operates as a multi-pass string transpiler. No abstract syntax tree is built. Instead, the input passes through an ordered pipeline of regex-based transformations. Order matters: environments are resolved before inline commands to prevent partial matches inside already-converted blocks.
Each stage applies a set of regular expressions. Brace-matching uses a non-recursive greedy approach with a custom matchBraces utility that counts nesting depth (d) starting at 1 after encountering {, incrementing on each {, decrementing on each }, and returning the substring when d = 0. For tabular environments, column separators (&) are mapped to wiki pipe delimiters (||) and row separators (\\) to new table rows (|-).
Where input = raw LaTeX source string, output = MediaWiki-compatible wikitext. The stripPreamble function removes everything before \begin{document} and after \end{document} if present. The convertMath function wraps remaining TeX math in <math> tags, preserving the LaTeX math syntax that MediaWiki's Texvc engine understands natively.
Reference Data
| LaTeX Command | Wikitext Output | Category |
|---|---|---|
| \section{Title} | == Title == | Sectioning |
| \subsection{Title} | === Title === | Sectioning |
| \subsubsection{Title} | ==== Title ==== | Sectioning |
| \textbf{text} | '''text''' | Formatting |
| \textit{text} / \emph{text} | ''text'' | Formatting |
| \underline{text} | <u>text</u> | Formatting |
| \texttt{text} | <code>text</code> | Formatting |
| $...$ / \(...\) | <math>...</math> | Inline Math |
| $$...$$ / \[...\] | <math display="block">...</math> | Display Math |
| \begin{equation} | <math display="block">...</math> | Math Environment |
| \begin{align} | <math display="block">\begin{align}...</math> | Math Environment |
| \begin{itemize} | * item (per line) | Lists |
| \begin{enumerate} | # item (per line) | Lists |
| \begin{description} | ; term : definition | Lists |
| \begin{tabular}{|c|c|} | Wiki pipe table {| class="wikitable" |} | Tables |
| \href{url}{text} | [url text] | Links |
| \url{url} | [url] | Links |
| \footnote{text} | <ref>text</ref> | References |
| \cite{key} | <ref name="key" /> | References |
| \label{key} | <span id="key"></span> | References |
| \ref{key} | [[#key]] | References |
| \includegraphics{file} | [[File:file|thumb]] | Media |
| \begin{verbatim} | <pre>...</pre> | Code |
| \begin{quote} | <blockquote>...</blockquote> | Block |
| \begin{center} | <div style="text-align:center">...</div> | Block |
| \newpage / \clearpage | (removed) | Layout |
| \\ | <br /> | Layout |
| \&, \%, \#, \$ | &, %, #, $ | Escapes |
| \LaTeX | LaTeX | Special |