Difference between revisions of "MediaWiki Include"

From Noah.org
Jump to navigationJump to search
Line 13: Line 13:
 
the extension to use "svn cat" to include the file from an SVN repository.
 
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 <strong>src="URL"</strong>
 
In this case the "src" argument will be passed directly to SVN, so <strong>src="URL"</strong>
may be any URL that SVN understand (file:///, svn+ssh://, webdav://, http://).  
+
may be any URL that SVN understand (file:, svn+ssh:, webdav:, http:).  
 
This is very handy for documenting source code.
 
This is very handy for documenting source code.
  

Revision as of 01:35, 23 August 2007


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.

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