User:Barre/MediaWiki/Extensions/kw include file: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(Extract the doc straight from the source)
 
m (add trace)
Line 1: Line 1:
{{User:Barre/Template/Header}}
<kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb|pre=0|wiki_markup=1|collapse_par=1|preg_match=/.*\/\*\s*(==.*?)^\*\//sm</kw_include_file>
<kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb|pre=0|wiki_markup=1|collapse_par=1|preg_match=/.*\/\*\s*(==.*?)^\*\//sm</kw_include_file>



Revision as of 19:19, 21 February 2005

<kw_bread_crumbs>prefix=» |small=1|bgcolor=F9F9F9|trim_prefix=User:|on_top_hack=1</kw_bread_crumbs> <kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb%7Cpre=0%7Cwiki_markup=1%7Ccollapse_par=1%7Cpreg_match=/.*\/\*\s*(==.*?)^\*\//sm</kw_include_file>

Examples

First let's include a simple small file:

<kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/README.txt?root=kwGrid</kw_include_file>

...is rendered as: <kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/README.txt?root=kwGrid</kw_include_file>

Now for something more complex. Note that the whole documentation above this section is included straight from the extension code itself ! Here is how it is done:

<kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb|pre=0|wiki_markup=1|collapse_par=1|preg_match=/.*\/\*\s*(==.*?)^\*\//sm</kw_include_file>

The hairy URL is followed by several options. The pre=0 parameter means that we do not want the text to be inserted verbatim inside PRE.../PRE tags. The wiki_markup=1 parameter specifies that the text is to be interpreted as Wiki markup. The (optional) collapse_par=1 parameter helps the Wiki engine by collapsing lines into paragraphs. The preg_match parameter specificies a regular expression that is used to extract only the documentation portion of the remote file: nothing fancy here, we are just looking for the string starting with == right inside a PHP comment /* ... */.