MediaWiki Include

From Noah.org
Revision as of 13:02, 12 October 2007 by Root (talk | contribs)
Jump to navigationJump to search


Include

Often it is handy to include the contents of external files directly in an article instead simply linking to the file. This describes "include" -- a MediaWiki extension that lets you include external static content from the local file system; a remote URL; or a Subversion repository.

If the external text is source code then it can be optionally colorized with syntax highlighting. By default the text is automatically wrapped in a <pre></pre> tag and all HTML entities are escaped. This can be turned off if you want to include raw text or HTML.

Note that syntax coloring requires the Pear Text_Highlighter module. The <include> extension will run without Text_Highlighter, but the 'highlight' attribute will be disabled. If you try to use it without installing Text_Highlighter the include script will silently ignore the 'highlight' attribute.

You can optionally add the svncat attribute which tells the extension to use "svn cat" to include the file from an SVN repository. In this case the "src" argument will be passed directly to SVN, so src="URL" may be any URL that SVN understand (file:, svn+ssh:, webdav:, http:). This is very handy for documenting source code.

The Include script is also described in the [MediaWiki Extension section].

Download the include script

For example, the include script below is itself included in this article with the following include line:

 <include svncat src="file:///home/svn/src/mediawiki/extensions/include.php" highlight="php" />

That pulls the latest copy of code from SVN and generates the following output:

<include svncat src="file:///home/svn/src/mediawiki/extensions/include.php" highlight="php" />

 https://www.noah.org/mediawiki-1.34.2/index.php?title=MediaWiki_Include&action=purge

Credits

Thanks to Uli Knieper for the "wikitext" code.