MEDIAWIKI2LATEX(1)

πŸ’– MEDIAWIKI2LATEX(1) πŸ’–

okay so bestie, this is the mediawiki2latex page from the User Commands manual, and it's literally the glow-up pipeline you've been waiting for: it grabs MediaWiki pages and compiles them, through LaTeX, all the way into a PDF. no cap. let's get into it πŸ¦‹


✨ SYNOPSIS ✨

mediawiki2latex [OPTION] -o FILE -u URL

that's it. that's the whole vibe. give it a URL, tell it where the PDF goes, and it works. πŸ’…


🌸 DESCRIPTION 🌸

okay so here's the tea: MediaWiki to LaTeX will fetch MediaWiki pages from a URL. and not just the one page, babe β€” it fetches all its content recursively, meaning subpages and pictures, the whole tree, no crumbs left behind. obsessed.

then the source code gets converted to LaTeX, using the user template MAP if you specified one, or a default template otherwise. if you gave it a LATEXTREE, the LaTeX output gets stored there. πŸ’Ύ

and finally β€” the main character moment β€” a PDF gets generated from the LaTeX source code if an appropriate LaTeX compiler is found. heads up though: it will automatically run several times to make sure all references are resolved, because references are dramatic like that and need a second (and third) pass. 😭

every single step can be controlled with command-line options. iconic.


✨ OPTIONS ✨

  • -c, --copy=LATEXTREE β€” write all generated LaTeX files to the specified folder.
  • -g, --vector β€” keep vector graphics in vector form. ✨ (yes bestie, they stay crisp, we love to see it)
  • -h, --html β€” use mediaWiki generated HTML as input. this one is the default, so it's already on unless you say otherwise.
  • -z, --zip β€” output LaTeX Source Archive. πŸ“¦
  • -b, --epub β€” output an epub file. ⚠️ only works if the packages latex2rtf and calibre are installed additionally.
  • -d, --odt β€” output an odt file. Open Document Text (for wordprocessors). ⚠️ only works if the packages latex2rtf and libreoffice are installed additionally.
  • -i, --internal β€” use internal template definitions.
  • -x, --hex=CONFIG β€” take configuration data from a hex encoded string given on the command line. this is only needed to avoid malicious shell injection via the web form of the server. πŸ”’ stay safe out there.
  • -m, --mediawiki β€” use mediaWiki to expand the templates.
  • -k, --bookmode β€” use book-namespace mode for expansion. that means: follow all links but not recursively.
  • -o, --output=FILE β€” specify the PDF output file.
  • -p, --paper=SIZE β€” set the paper size. possible values are A4, A5, B5, letter, legal, executive.
  • -r, --resolution=DPI β€” set the maximum image resolution in dot-per-inch. the argument should be an integer.
  • -s, --server=PORT β€” run as server. listen on PORT. πŸ–₯️
  • -t, --templates=MAP β€” specify the user template map file. usually called templates.user.
  • -l, --headers=EADERSPATH β€” the path to the LaTeX headers which should be used. may be omitted. useful in combination with -t.
  • -u, --url=URL β€” the input URI. it should point to a MediaWiki page.
  • -?, -v, --version, --help β€” show help options together with version number. 🫢

πŸŽ€ TEMPLATES πŸŽ€

so MediaWiki has this genuinely powerful template system that controls the appearance of specific parts in the text. and bestie, we can use that to our advantage β€” to further control the appearance of the resulting PDF. main character energy for real.

you can tell MediaWiki to LaTeX to use the host site template result directly in the PDF, or you can use a custom template of your own. want a template example? peek at $XDG_DATA_DIRS/mediawiki2latex/latex. go look, it's giving inspiration. πŸ’–


🧚 LATEX TREE 🧚

okay so all the downloaded files are kept into memory, which means there will not be any MediaWiki files remaining on disk after the process finishes. clean. ✨

but β€” plot twist β€” the generated LaTeX files (the LaTeX tree) need to be written on disk in order to produce the PDF. by default these files are written to /tmp/MediaWiki$$. and that folder? it gets removed when the program exits. bye bye. πŸ’€

however (dramatic pause), you may want to keep the generated LaTeX tree on disk for LaTeX customization and to fasten future builds. πŸ‘€ if you use the -c option to set the LaTeX tree folder, the program will not remove it on exit, so you can continue to use it. keep it forever, bestie.

the LaTeX tree is made of three folders:

  • header β€” a folder containing the LaTeX options, the special pages, the package loading, etc.
  • images β€” all the original picture files used in the article. πŸ–ΌοΈ
  • main β€” the complete LaTeX version of the source document is stored in main.tex.

to compile the PDF file yourself, simply run xelatex on the main.tex file. for instance:

xelatex LaTeX-tree/main/main.tex

you may need to run it several times to make sure all references are resolved. (again. they're needy. it's fine.)


πŸ‘‘ AUTHORS πŸ‘‘

MediaWiki to LaTeX was mainly developed by Dirk HΓΌnniger <dirk.hunniger@googlemail.com>. other contributors are listed in the AUTHORS file. absolute legends, all of them.

this man page was written by Pierre Neidhardt <ambrevar@gmail.com>.


and that's the whole page bestie!! πŸŽ€ this is MediaWiki to LaTeX 8.41, dated 2013-12-25 β€” yeah it's a vintage icon but she still slays. so go forth, compile some wikis into PDFs, and remember: run xelatex a few times or your references will simply not resolve. periodt. πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from