Skip to content
7800ukPublic

About

Org HTML export in MediaWiki's skins — Vector legacy and MonoBook, with source, PDF and git-history pages

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ox-wiki — Org HTML export in MediaWiki’s skins

An Org export backend that makes an exported file look like a MediaWiki article: content column, tab row, sidebar, wiki footer. Four skins ship with it — vector (Vector legacy, the 2010 Vector, which is what vector still means in MediaWiki next to vector-2022), monobook, citizen (the StarCitizenTools skin), and 7800, Citizen as https://7800.io/ wears it: icons that stay as they are when hovered, and performance mode always on, with no switch for it — and the skin is a parameter, not a fork; see SKINS.org for writing another, in this repository or your own.

Beside the article it writes the pages its tabs point at: a read-only view of the Org source and of the LaTeX export, a PDF, and, for a git-tracked file, a revision history with MediaWiki-style diffs.

Each page is a single self-contained .html file. The stylesheet, every icon, the logo, the footer buttons and, for Citizen, the scripts are inlined, so there is nothing to copy alongside.

Using it

With straight.el:

(use-package ox-wiki
  :straight (ox-wiki :host github :repo "7800uk/ox-wiki"
                     :files ("*.el" "COPYING" "css" "js" "images"))
  :after ox)

From a clone, without a package manager:

(add-to-list 'load-path "~/Development/ox-wiki")
(require 'ox-wiki)

Then from any Org buffer:

KeyDoes
C-c C-e w wexport to a file
C-c C-e w Wexport to a buffer
C-c C-e w oexport to a file and open it

For org-publish, use org-wiki-publish-to-html as the :publishing-function. The ordinary HTML backend is untouched; C-c C-e h h still does what it did.

To see it, rebuild the demo and open demo/Demo.html:

emacs -Q --batch -l demo/build.el

Per-file settings

All of these have a defcustom of the same name behind them (#+WIKI_TYPE ↔ org-wiki-type), so a wiki-wide default is set once and a page overrides it only where it differs.

KeywordWhat it sets
#+WIKI_SKINvector, monobook, citizen or 7800
#+WIKI_SITENAMEthe name in the search box
#+WIKI_TAGLINEthe line under the page title
#+WIKI_TYPEwhat the leftmost tab says; default “Article”
#+WIKI_LOGOan image file to use as the wiki logo
#+WIKI_HOMEwhere the logo points
#+WIKI_SIDEBARan Org file describing the sidebar
#+WIKI_BUTTONSa footer button; repeat the line for more
#+WIKI_SEARCH_BOXt shows the search box; off by default
#+WIKI_SEARCHwhere the search box posts
#+WIKI_LOGINt shows the personal menu and “Log in”; off by default
#+WIKI_LOGIN_URLwhere “Log in” points
#+WIKI_PERSONALa link before “Log in”, as (TEXT HREF); nil for none
#+WIKI_FOOTER_PLACESa footer link, as (TEXT HREF); nil for none
#+WIKI_FOOTER_NOTICEthe footer’s attribution line; empty for none
#+WIKI_CREDITnil drops the skin’s credit from the footer
#+WIKI_LATEXnil drops the LaTeX source and the PDF
#+WIKI_PDFnil keeps the LaTeX source but drops the PDF
#+WIKI_GITnil drops the revision history

The logo

#+WIKI_LOGO: logo.svg

Looked for beside the Org file first, then in this package, then as an absolute path. It is inlined, so any raster or vector format a browser reads will do. images/logo.svg is the fallback; replace that file to change the default for every page at once.

Footer buttons

One per line, each a Lisp list of (IMAGE HREF ALT) — HREF and ALT optional:

#+WIKI_BUTTONS: ("images/poweredby_org.svg" "https://orgmode.org/" "Powered by Org mode")
#+WIKI_BUTTONS: ("cc-by-sa.svg" "https://creativecommons.org/licenses/by-sa/4.0/" "CC BY-SA 4.0")

Images are resolved and inlined the same way as the logo.

The sidebar

#+WIKI_SIDEBAR: Sidebar.org

Each first-level heading in that file becomes a portlet, and each list item under it becomes a link. An item with no link becomes plain text. Anything else in the file — a title, prose between the headings — is ignored, so the file is readable on its own:

* Navigation
- [[file:index.html][Main page]]
- [[file:all.html][All pages]]

* Tools
- [[javascript:print();][Printable version]]

The path is resolved against the exported file’s directory. Without the keyword, org-wiki-default-sidebar is used. Note that MediaWiki hides the first portlet’s heading — the one right under the logo — which is why “Navigation” does not appear above its links. That is the skin, not a bug.

Search and logging in

Neither is drawn unless asked for: an exported page has no wiki to search and nobody to log in. Both are wiki-wide choices, so they sit best in a setup file the pages share:

#+WIKI_SEARCH_BOX: t
#+WIKI_SEARCH: https://duckduckgo.com/
#+WIKI_LOGIN: t
#+WIKI_LOGIN_URL: https://wiki.example.org/login

and in each page:

#+SETUPFILE: wiki-setup.org

The search box is a plain GET form posting its text as q (org-wiki-search-field) to #+WIKI_SEARCH, so any endpoint that takes a query that way will do. The login link goes after the links in org-wiki-personal-tools, “Not logged in” by default.

The pages the tabs lead to

For Foo.org, an export writes:

FileTab
Foo.htmlRead
Foo-source.htmlView source → Org source
Foo-source-latex.htmlView source → LaTeX source
Foo.pdfView PDF
Foo-history.htmlView history

The source views imitate MediaWiki’s read-only “view source” page, which is the closest thing a wiki has to what this is. There is nothing to save to, so the button a wiki would label “Publish changes” says Download source and hands you the text as a data: URI — no server involved.

The history page reads git log for the file and renders each revision’s diff in MediaWiki’s two-column diff table, with cur and prev links that jump to them. Renames are not followed, so a file only has history under the path it has now, and only the revisions listed get diffs (org-wiki-history-limit, 40 by default).

A tab appears only when it can: no LaTeX binary means no PDF tab, an untracked file means no history tab, and #+WIKI_LATEX: nil or #+WIKI_GIT: nil turns them off by hand. If LaTeX is installed but the run fails, that is reported and the PDF tab is left pointing at a file that is not there — the article is rendered before LaTeX is run, so the tab has already been decided.

What is in here

PathWhat it is
ox-wiki.elthe backend: options, skin dispatch, page assembly, TOC
ox-wiki-pages.elthe source views, the PDF, the history and the diff pages
ox-wiki-skin-vector.elthe Vector legacy skin
ox-wiki-skin-monobook.elthe MonoBook skin
ox-wiki-skin-citizen.elthe Citizen skin
ox-wiki-skin-7800.elCitizen with still icons and performance mode always on
SKINS.orghow to write another
css/org-wiki.csshand-written: Org’s markup mapped onto the skins
css/7800.csshand-written: what the 7800 skin changes in Citizen’s look
css/vector.css, css/monobook.css, css/citizen.cssgenerated. The skins’ own stylesheets
css/mediawiki-extras.cssgenerated. MediaWiki’s diff and edit-font styles
js/mediawiki.js, js/citizen-search.js, js/7800.jsthe only hand-written scripts: a stand-in for MediaWiki’s client runtime, for Citizen’s command palette, and the 7800 skin’s lock on performance mode
js/citizen.jsgenerated. Citizen’s scripts
vendor/those stylesheets, icons and scripts, exactly as served
images/the default logo and footer badge
tools/build-css.pyrebuilds everything in css/ except org-wiki.css
tools/build-js.pyrebuilds js/citizen.js
demo/a crowded page in each skin, and build.el to rebuild it
COPYINGGPL-2.0, from the Vector repository

Only *.el, css/, js/ and images/ are needed at run time; vendor/, tools/ and demo/ are build-time only, which is why the straight recipe above ships just those.

Nothing generated is checked in. demo/ holds only sources, and demo/build.el writes every page into build/, which is ignored.

Where the stylesheets and scripts came from

vendor/*/\*.raw.css are ResourceLoader builds, fetched from en.wikipedia.org on 2026-10-19:

.../load.php?modules=mediawiki.skins.legacy|skins.vector.styles.legacy&only=styles&skin=vector
.../load.php?modules=mediawiki.skins.legacy|skins.monobook.styles&only=styles&skin=monobook
.../load.php?modules=mediawiki.diff.styles|mediawiki.editfont.styles|mediawiki.action.styles|mediawiki.interface.helpers.styles&only=styles&skin=vector

vendor/citizen/citizen.raw.css is the same thing for Citizen, which Wikipedia does not run, so it was fetched on 2026-10-20 from starcitizen.tools, the wiki the skin is written for (Citizen 3.24.0):

.../load.php?modules=mediawiki.action.history.styles|mediawiki.diff.styles|mediawiki.editfont.styles|mediawiki.interface.helpers.styles|mediawiki.notification|mediawiki.page.ready|skins.citizen.codex.styles|skins.citizen.icons,styles|skins.citizen.tokens.new&only=styles&skin=citizen

The core modules in that list are there because Citizen restyles them: the notifications and dialogs its scripts open, and the diffs, history and source views of the companion pages.

Its icons are the ones that stylesheet asks ResourceLoader for, saved from the same wiki as vendor/citizen/images/NAME.svg, plus the three Citizen ships in resources/skins.citizen.styles/assets/images/. Citizen’s web fonts, Roboto Flex and Roboto Mono, are left out: tools/build-css.py drops them rather than inline them, because Citizen points five @font-face rules at each file and the page would grow by the best part of a megabyte. Where Roboto is installed it is still used; elsewhere the text falls back to the system sans-serif.

vendor/citizen/citizen.raw.js is Citizen’s scripts from the same wiki, with the vue module they need, again exactly as ResourceLoader serves them:

.../load.php?modules=skins.citizen.preferences|skins.citizen.scripts|skins.citizen.share|skins.citizen.toc|vue&skin=citizen

That is a run of mw.loader.impl() calls, which on a wiki land in the mw that MediaWiki’s startup module defines. An exported page has no wiki to define it, so js/mediawiki.js does instead: a small, hand-written stand-in for the client runtime — the module loader and require, mw.config, hooks, messages, mw.util, mw.storage, notifications — covering only what the vendored modules call, and fetching nothing. tools/build-js.py copies the modules into js/citizen.js untouched except for configuration ResourceLoader generates from the serving wiki’s settings: starcitizen.tools defaults to the dark theme, and the build puts back Citizen’s own default, which follows the reader’s system.

With it come Citizen’s preferences panel (theme, text size, width, saved in the browser), the share dialog, the sticky header, collapsible sections, the contents’ scroll-tracking, the relative “last modified” time, and the page tabs folding into a menu on narrow screens. The one part that needs a wiki behind it, the command palette, searches the wiki’s API, so js/citizen-search.js takes its place: / and Ctrl+K open the page’s own search box, which posts to org-wiki-search-action. Without JavaScript the page still works, since Citizen’s menus are <details> elements its stylesheet opens.

The scripts make a Citizen page about 500 KiB heavier, most of it Vue and the preferences panel; org-wiki-style-method link shares them between pages instead. css/org-wiki.css’s syntax-highlighting colours are a light palette, and read poorly in Citizen’s dark theme.

The MediaWiki skins’ stylesheets are compiled artefacts rather than the LESS sources in mediawiki-skins-Vector and mediawiki-skins-MonoBook, because those import variables and mixins from MediaWiki core and cannot be compiled on their own. The icons under vendor/*/images/ are from those repositories, plus a few from MediaWiki core’s mediawiki.skinning, and they sit in vendor/<skin>/images/.

tools/build-css.py turns each raw file into the matching file in css/. It changes nothing but the url() references: icons become data: URIs, and the project logo is blanked so the per-page logo rule can take over. Keep edits out of the generated files — they are overwritten — and put them in css/org-wiki.css.

To refresh against a newer upstream, replace the raw file and re-run:

python3 tools/build-css.py

Why a backend rather than ox-html and a stylesheet

org-html-template hardcodes a skeleton — preamble div, content div, postamble div — and a wiki skin needs a different one:

<div id="content" class="mw-body" role="main">
  <h1 id="firstHeading" class="firstHeading">…</h1>
  <div id="bodyContent" class="vector-body">
    <div id="mw-content-text" class="mw-body-content">
      <div class="mw-parser-output"> … </div>

Those wrappers carry most of the skin’s typography (.vector-body p, .vector-body h2, .mw-parser-output a.external and several hundred more), and they cannot be opened in a preamble and closed in a postamble: Org wraps the postamble in its own div inside the still-open one. Retargeting the selectors instead would mean forking the vendored stylesheet by hand, which is exactly what keeping it a regenerable copy avoids.

So the backend replaces two functions, template and inner-template, and inherits every other transcoder from ox-html. On top of that it:

  • numbers the table of contents the way MediaWiki does — in MediaWiki’s own #toc markup, with the pure-CSS [hide] toggle — while leaving the headings unnumbered, which is what a wiki article looks like. #+OPTIONS: num:t still numbers the headings;
  • puts the contents box after the lead paragraphs rather than above them;
  • gives every table MediaWiki’s wikitable class, unless an #+ATTR_HTML line already set one;
  • marks absolute links class“external text”=, which is what draws the arrow;
  • heads the footnote section “References” instead of “Footnotes”;
  • asks htmlize for class names rather than inline styles, so code colours come from css/org-wiki.css instead of from whatever theme Emacs is wearing. Syntax highlighting needs htmlize; without it, source blocks export as plain text.

Licence

Everything under vendor/ except vendor/citizen/, and everything the generated stylesheets other than css/citizen.css are built from, is MediaWiki’s: copyright the MediaWiki contributors, GPL-2.0-or-later; see COPYING. ox-wiki.el, ox-wiki-pages.el, the Vector and MonoBook skins, css/org-wiki.css, js/mediawiki.js, the tools/ and images/ are ours and carry the same licence. The vue module in js/citizen.js is MediaWiki’s too, around Vue.js, which is MIT-licensed.

vendor/citizen/, css/citizen.css and js/citizen.js are Citizen’s, and ox-wiki-skin-citizen.el and js/citizen-search.js follow its markup and code: copyright the Citizen contributors, GPL-3.0-or-later; see vendor/citizen/LICENSE. GPL-2.0-or-later code may be combined with GPL-3.0 code, so the package with Citizen in it is distributed under GPL-3.0; leave out those files for a GPL-2.0-only build.

“MediaWiki” and “Wikipedia” are trademarks of the Wikimedia Foundation. This is not a Wikimedia product, and the footer says so.

About

Org HTML export in MediaWiki's skins — Vector legacy and MonoBook, with source, PDF and git-history pages

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages