Open main menu

Extension:TEI


MediaWiki extensions manual
OOjs UI icon advanced.svg
TEI
Release status: experimental
Implementation ContentHandler
Description Implementation of a ContentHandler for TEI XML
Author(s) (Tpttalk)
Compatibility policy master
MediaWiki 1.33+
License GNU General Public License 2.0 or later
Download
README
Example demo wiki
Translate the TEI extension if it is available at translatewiki.net
Check usage and version matrix.
Issues Open tasks · Report a bug

The TEI extension makes MediaWiki compatible with TEI XML P5, allowing to use TEI instead of Wikitext in some or all wiki pages.

It is currently a work in progress. It aims at providing an implementation of a subset of TEI, probably inspired by TEI simplePrint with an XML editor and a WYSIWYG editor.

Currently only a small set of TEI tags are supported, excluding the TEI header. A simple XML editor is provided with validation and autocomplete based on a configurable ODD bundled with the extension. A (buggy) beginning of VisualEditor customization is also available. A demo wiki is updated daily with the latest version of the extension. A bug tracker dashboard is available.

InstallationEdit

  • Download and place the file(s) in a directory called TEI in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'TEI' );
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

This extension depends on the following extensions:

CodeMirror
in order to provide syntax highlight to the XML editor
VisualEditor
to provide a VisualEditor for TEI. Parsoid installation is not required to allow usage on servers without node.js.
Math
for math rendering.

By default the tei ContentModel is not enabled anywhere. You could, e.g. create a new namespace called "TEI" and enable TEI by default in it by adding to your LocalSettings.php:

define( 'NS_TEI', 100 );
define( 'NS_TEI_TALK', 101 );
$wgExtraNamespaces[NS_TEI] = 'TEI';
$wgExtraNamespaces[NS_TEI_TALK] = 'TEI_Talk';
$wgNamespaceContentModels[NS_TEI] = 'tei';

An other option is to use Special:ChangeContentModel to change the content model of some pages from "wikitext" to "TEI".

How to customize the TEI ODDEdit

A TEI ODD is used to define the validation of TEI content. It might also be used in the future to customize the HTML rendering. The ODD used by default is stored in the data/mw_customization.odd file of the extension git repository. After having modified it you should update the internal JSON definition file used directly by running php maintenance/GenerateTeiJsonDefinition.php from the main directory of the TEI extension.

How this extension workEdit

  • It defines a new content format in the TeiContentModel and TeiContent classes.
  • The class Model\TeiRegistry is used to provide access to the current ODD. It is read from the data/mw_tei_json_definition.json JSON file that is generated from an ODD (see previous section).
  • The class Model\Validator validates a DOM tree against a Model\TeiRegistry. It is written directly in PHP to get better error messages, building automata to validate node children and tags values.
  • The classes Model\TeiToHtmlConversion and Model\HtmlToTeiConversion handle the rountrip conversions between TEI and HTML.
  • There is a small set of unit tests in the tests folder, especially for the HTML from/to TEI conversion. The roundrip conversion tests are in tests/phpunit/Converter/roundtrip.txt file.