return $needsbuild;
}
+my $scanned = 0;
+
=for wiki
The `trail` directive is supplied by the [[plugins/contrib/trail]]
sub preprocess_trail (@) {
my %params = @_;
+ # avoid collecting everything in the preprocess stage if we already
+ # did in the scan stage
+ if (defined wantarray) {
+ return "" if $scanned;
+ }
+ else {
+ $scanned = 1;
+ }
+
if (exists $params{circular}) {
$pagestate{$params{page}}{trail}{circular} =
IkiWiki::yesno($params{circular});
=cut
sub preprocess_trailinline (@) {
- preprocess_trail(@_);
- return unless defined wantarray;
+ my %params = @_;
+
+ if (defined wantarray) {
+ scalar preprocess_trail(%params);
- if (IkiWiki->can("preprocess_inline")) {
- return IkiWiki::preprocess_inline(@_);
+ if (IkiWiki->can("preprocess_inline")) {
+ return IkiWiki::preprocess_inline(@_);
+ }
+ else {
+ error("trailinline directive requires the inline plugin");
+ }
}
else {
- error("trailinline directive requires the inline plugin");
+ preprocess_trail(%params);
}
}
my $link = shift;
shift;
+ # avoid collecting everything in the preprocess stage if we already
+ # did in the scan stage
+ if (defined wantarray) {
+ return "" if $scanned;
+ }
+ else {
+ $scanned = 1;
+ }
+
my %params = @_;
my $trail = $params{page};
$link = linkpage($2);
add_link($params{page}, $link, 'trail');
- push @{$pagestate{$params{page}}{trail}{contents}}, "link $link";
+
+ # avoid collecting everything in the preprocess stage if we already
+ # did in the scan stage
+ my $already;
+ if (defined wantarray) {
+ $already = $scanned;
+ }
+ else {
+ $scanned = 1;
+ }
+
+ push @{$pagestate{$params{page}}{trail}{contents}}, [link => $link] unless $already;
if (defined $linktext) {
$linktext = pagetitle($linktext);