diff --git a/data/System/FilterPlugin.txt b/data/System/FilterPlugin.txt index b5e312d..26431a4 100644 --- a/data/System/FilterPlugin.txt +++ b/data/System/FilterPlugin.txt @@ -90,6 +90,7 @@ prepended with a header and appended with a footer in case the list is not empty * footer="...": footer string * separator="...": string to be inserted between list items * null="...": the format string to render the empty list + * hideempty="on,off": when set to "on" then empty list items will not be added to the result (empty in the sense of ''); set this to "off" to still add them (default "on") * limit="...": max number of items to be taken out of the list (default "-1") * skip="...": number of list items to skip, not adding them to the result * sort="on,off,alpha,num,nocase" order of the formatted items (default "off") @@ -258,11 +259,12 @@ compare with [[http://en.wikipedia.org/wiki/Category:Philosophy_articles_needing * Set SHORTDESCRIPTION = Substitute and extract information from content by using regular expressions --> | Plugin Author: | Michael Daum | -| Copyright ©: | 2005-2011, Michael Daum http://michaeldaumconsulting.com | +| Copyright ©: | 2005-2012, Michael Daum http://michaeldaumconsulting.com | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | | Release: | %$RELEASE% | | Version: | %$VERSION% | | Change History: |   | +| 10 Jan 2012: | fixed filtering zero; fixed counting list items without formating them; added =hideempty= parameter to enable/disable rendering empty list items | | 29 Sep 2011: | fixed SUBST macro =topic= param processing embedded META | | 25 Aug 2011: | fixed perl rookie error initializing defaults | | 14 Jul 2011: | fixed parsing zero values in lists (by Grzegorz Marszalek) | diff --git a/lib/Foswiki/Plugins/FilterPlugin.pm b/lib/Foswiki/Plugins/FilterPlugin.pm index 6e74a90..4686d84 100644 --- a/lib/Foswiki/Plugins/FilterPlugin.pm +++ b/lib/Foswiki/Plugins/FilterPlugin.pm @@ -1,6 +1,6 @@ # Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/ # -# Copyright (C) 2005-2011 Michael Daum http://michaeldaumconsulting.com +# Copyright (C) 2005-2012 Michael Daum http://michaeldaumconsulting.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -25,7 +25,7 @@ use vars qw( ); $VERSION = '$Rev$'; -$RELEASE = '2.07'; +$RELEASE = '2.08'; $NO_PREFS_IN_TOPIC = 1; $SHORTDESCRIPTION = 'Substitute and extract information from content by using regular expressions'; diff --git a/lib/Foswiki/Plugins/FilterPlugin/Core.pm b/lib/Foswiki/Plugins/FilterPlugin/Core.pm index a086e4c..ca7fa81 100644 --- a/lib/Foswiki/Plugins/FilterPlugin/Core.pm +++ b/lib/Foswiki/Plugins/FilterPlugin/Core.pm @@ -1,6 +1,6 @@ # Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/ # -# Copyright (C) 2005-2011 Michael Daum http://michaeldaumconsulting.com +# Copyright (C) 2005-2012 Michael Daum http://michaeldaumconsulting.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -93,7 +93,7 @@ sub handleFilter { # get the source text my $text = ''; - if ($theText) { # direct text + if (defined $theText) { # direct text $text = $theText; } else { # topic text return '' if $filteredTopic{"$theWeb.$theTopic"}; @@ -529,6 +529,7 @@ sub handleFormatList { my $theMap = $params->{map}; my $theNullFormat = $params->{null} || ''; my $theTokenize = $params->{tokenize}; + my $theHideEmpty = Foswiki::Func::isTrue($params->{hideempty}, 1); $theFormat = '$1' unless defined $theFormat; @@ -637,7 +638,7 @@ sub handleFormatList { next if $seen{$line}; $seen{$line} = 1; } - next if $line eq ''; + $line =~ s/\$index/$count+1/ge; if ($theSelection && $item =~ /$theSelection/) { $line =~ s/\$marker/$theMarker/g @@ -645,7 +646,7 @@ sub handleFormatList { $line =~ s/\$marker//go; } if ($skip-- <= 0) { - push @result, $line; + push @result, $line unless ($theHideEmpty && $line eq ''); $count++; last if $theLimit - $count == 0; }