Extension:HTML Tags

HTML Tags is an extension to MediaWiki that defines a tag,, that can be used to display HTML tags within wiki pages that may otherwise be disallowed by the MediaWiki parser. Significantly, this allows Mediawiki to support the use of LRMI and similar metadata standards.

You can see a demonstration of this extension here.

Code and download
You can download the HTML Tags code, in .tgz format, here.

You can also download the code directly via Git from the MediaWiki source code repository. From a command line, you can call the following:

To view the code online, including version history for each file, go here.

Installation
After you've obtained an 'HTMLTags' directory (either by extracting a compressed file or downloading via SVN), place this directory within the main MediaWiki 'extensions' directory. Then, in the file 'LocalSettings.php' in the main MediaWiki directory, add the following line:

You then need to specify the allowed set of HTML tags, and the allowed set of attributes for each one, using the global variable $wgHTMLTagsAttributes. For instance, to allow the  tag, and to allow only the attributes "href" and "class" for it, you would add the following to LocalSettings.php, after the inclusion of LocalSettings.php:

If you wanted to allow the tag, but without any allowed attributes, you would add the following:

Usage
Once a set of allowed tags and attributes are specified, you can use to place those tags on the page. You use the attribute "tagname" to specify the actual tag, and then add the other attributes exactly as you want them to appear. The "contents" of the tag become the contents of.

For instance, if the above lines are added, and you want to add a link on some page using the  tag, you could add something to the page like:
 * Read about Antarctica

This will add the following to the page's HTML source:
 * Read about Antarctica

Calling with a tag name that is not allowed will result in an error message; calling it with an attribute that is not allowed will simply lead to the attribute being ignored.

LRMI, schema.org, and other meta-data
HTML Tags was designed to support LRMI, a metadata standard for open educational resources developed by Creative Commons. The full specification for LRMI can be found here. HTML Tags can also support the use of schema.org parameters with no additional work (except for adding schema.org parameters to the necessary templates,) and should be able to support most other meta-data schemas with some tinkering. Implementing LRMI with HTML Tags requires enabling two HTML tags, meta and span, since both of those tags are necessary to create LRMI metadata that verifies against Google’s rich text snippet testing tool. Although there are many ways to implement LRMI once these tags are enabled, we’ve written a series of templates that can be used for this purpose.

If you’d like to use LRMI on your wiki, you should be able to directly copy over these templates and successfully use them. If you try to implement this template structure and run in to any problems, please drop a note on the talk page here or email Max at isalix@undefinedgmail.com - we'd be more than happy to get you up and running with LRMI and HTML Tags.

is a template that can be used to tag a page with multiple LRMI properties at once. For most purposes, this is probably the template you will want to use to add LRMI data to your page. The template by default contains all LRMI properties, if any do not apply to your page you can simply leave them blank. This template is especially useful when used in conjunction with adding a button to the standard editing window with WikiEditor. It should be called in the following format:

Here’s the code for the template itself. It should work on any standard Mediawiki installation that has HTML Tags installed, meta and span tags enabled, and the dependent templates present.

is a template that can be used to tag a page with one specific LRMI property. In most situations it is desirable to use in place of this template, but we’ve included it anyway for comprehensiveness. It should be called in the following format:

Here’s the code for the template, which should work on any standard MediaWiki installation that has HTML Tags installed, the meta and span tags enabled, and the dependent templates present:

is a template called by and. It should be called in the following fashion:

Here’s the code for the template, which should work on any standard MediaWiki installation that has HTML Tags installed and the meta tag enabled:

is a template called by and. It should be called in the following fashion:

Here’s the code for the template, which should work on any standard MediaWiki installation that has HTML Tags installed and the meta tag enabled:

Authors
HTML Tags was written by Yaron Koren, reachable at yaron57 -at- gmail.com.

This extension was funded by Creative Commons as part of the LRMI project.

Version history
HTML Tags is currently at version 0.1.

The version history is:
 * 0.1 - November 1, 2012 - Initial version