key Log In

You are here: wiki.fini > TWiki Web > FilterPlugin

Start of topic | Skip to actions

FilterPlugin

This plugin allows to substitute and extract information from content by using regular expressions.

Syntax Rules

SUBST

Syntax: %SUBST{topic="..." ...}%

insert a topic by processing its content.

  • topic="...": name of the topic text to be processed
  • pattern="...": pattern to be extracted or substituted
  • format="...": format expression or pattern substitute
  • hits="<n>" number of occurences to extract or substitute counted from the start of the text (defaults to 0 aka all hits)
  • expand="on,off": toggle expansion of TWiki markup before filtering (defaults to on)

STARTSUBST, STOPSUBST

Syntax:
%STARTSUBST{...}% 
... 
%STOPSUBST%

substitute text given inline. see SUBST.

EXTRACT

Syntax:=%EXTRACT{topic="..." ...}%=

extract text from a topic. see SUBST.

STARTEXTRACT, STOPEXTRACT

Syntax:
%STARTEXTRACT{...}% 
... 
%STOPEXTRACT%

extract content given inline. see SUBST.

FORMATLIST

Syntax: =%FORMATLIST{"<list>" ...}%

formats a list of items. The <list> argument is separated into items by using a split expression; each item is matched agains a pattern and then formatted using a format string while being separated by a separator string; the result is prepended with a header and appended with a footer in case the list is not empty.

  • <list>: the list
  • split="...": the split expression (default ",")
  • pattern="...": pattern applied to each item (default "\s(.*)\s")
  • format="...": the format string for each item (default "$1")
  • header="...": header string
  • footer="...": footer string
  • separator="...": string to be inserted between list items
  • limit="...": max number of items to be taken out of the list (default "-1")
  • sort="on,off,alpha,num" order of the formatted items (default "off")
  • reverse="on,off": reverse the sortion of the list
  • unique="on,off": remove dupplicates from the list
  • exclude="...": remove list items that match this regular expression
The pattern string shall group matching substrings in the list item to which you can refer to by using $1, $2, ... in the format string. Any format string (format, header, footer) may contain variables $percnt$, $nop, $dollar and $n. The variable $index referse to the position number within the list being formatted; using $count in the footer or header argument refers to the total number of list elements.

Examples

Secure Html

<a href="javascript:window.alert('Pop me up');">Pop me up</a>

Format Comments

Date Author Headline
22 Aug 2005 TWiki:Main.MichaelDaum This is a first comment. ...
22 Aug 2005 TWiki:Main.MichaelDaum This is a second comment. ...

This is a first comment. This is a first comment. This is a first comment.
-- TWiki:Main.MichaelDaum on 22 Aug 2005

This is a second comment.
-- TWiki:Main.MichaelDaum on 22 Aug 2005

Plugin Settings

  • Set SHORTDESCRIPTION = Substitute and extract information from content by using regular expressions

Plugin Installation Instructions

  • Download the ZIP file from the Plugin web (see below)
  • Unzip FilterPlugin.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/FilterPlugin.txt Plugin topic
    lib/TWiki/Plugins/FilterPlugin.pm Plugin Perl module
  • (Dakar) Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.

Plugin Info

Plugin Author: TWiki:Main.MichaelDaum
Copyright ©: 2005-2006, Michael Daum
License: GPL (GNU General Public License)
Plugin Version: v0.94
Change History:  
14 Feb 2006: moved in FORMATLIST from the TWiki:Plugins/NatSkinPlugin; added escape variables to format strings
06 Dec 2005: fixed SUBST not to cut off the rest of the text
09 Nov 2005: fixed deep recursion using expand="on"
22 Aug 2005: Initial version; added expand toggle
TWiki Dependency: $TWiki::Plugins::VERSION 1.024
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
TWiki:Plugins/Benchmark: GoodStyle nn%, FormattedSearch nn%, FilterPlugin nn%
Plugin Home: TWiki:Plugins/FilterPlugin
Feedback: TWiki:Plugins/FilterPluginDev
Appraisal: TWiki:Plugins/FilterPluginAppraisal

-- TWiki:Main.MichaelDaum - 14 Feb 2006

This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding wiki.fini? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.FilterPlugin