summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/tag.pm31
-rw-r--r--IkiWiki/Render.pm9
2 files changed, 38 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm
new file mode 100644
index 000000000..841d508bf
--- /dev/null
+++ b/IkiWiki/Plugin/tag.pm
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+# Ikiwiki tag plugin.
+package IkiWiki::Plugin::tag;
+
+use warnings;
+use strict;
+use IkiWiki;
+
+my %tag;
+
+sub import { #{{{
+ IkiWiki::hook(type => "preprocess", id => "tag", call => \&preprocess);
+} # }}}
+
+sub preprocess (@) { #{{{
+ if (! @_) {
+ return "";
+ }
+ my %params=@_;
+ my $page = $params{page};
+ delete $params{page};
+
+ foreach my $tag (keys %params) {
+ # hidden WikiLink
+ push @{$IkiWiki::links{$page}}, $tag;
+ }
+
+ return "";
+} # }}}
+
+1
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index e5a1679f8..690945c49 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -105,8 +105,13 @@ sub preprocess ($$;$) { #{{{
# Note: preserve order of params, some plugins may
# consider it significant.
my @params;
- while ($params =~ /(\w+)=\"?([^"]+)"?(\s+|$)/g) {
- push @params, $1, $2;
+ while ($params =~ /(?:(\w+)=)?(?:"([^"]+)"|(\S+))(?:\s+|$)/g) {
+ if (defined $1) {
+ push @params, $1, (defined $2 ? $2 : $3);
+ }
+ else {
+ push @params, (defined $2 ? $2 : $3), '';
+ }
}
return $hooks{preprocess}{$command}{call}->(@params, page => $page);
}