From 73253d6925ef84f9dd9e72919f8a136b93a0d277 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 26 Jan 2010 22:26:50 -0500 Subject: template: Preprocess parameters before htmlizing. Consider a template like: [[!template type=note text=""" [[!inline pages="*foo*"]] """]] The text parameter is htmlized before being passed into the template (in case the template wraps it in a that prevents markdown from htmlizing it later). But, when markdown sees "*foo*", it turns that into foo. Later, when preprocessing the inline directive, that leads to suprising results. To fix this, I made template parameters be preprocessed (and filtered) before being htmlized. Note that I left in the preprocessing (and filtering) of the template output at the end. That's still relevant when the template itself contains preprocessor directives. --- IkiWiki/Plugin/template.pm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm index b6097bb49..39d9667f9 100644 --- a/IkiWiki/Plugin/template.pm +++ b/IkiWiki/Plugin/template.pm @@ -25,6 +25,10 @@ sub getsetup () { sub preprocess (@) { my %params=@_; + # This needs to run even in scan mode, in order to process + # links and other metadata included via the template. + my $scan=! defined wantarray; + if (! exists $params{id}) { error gettext("missing id parameter") } @@ -58,24 +62,23 @@ sub preprocess (@) { $params{basename}=IkiWiki::basename($params{page}); foreach my $param (keys %params) { + my $value=IkiWiki::preprocess($params{page}, $params{destpage}, + IkiWiki::filter($params{page}, $params{destpagea}, + $params{$param}), $scan); if ($template->query(name => $param)) { $template->param($param => IkiWiki::htmlize($params{page}, $params{destpage}, pagetype($pagesources{$params{page}}), - $params{$param})); + $value)); } if ($template->query(name => "raw_$param")) { - $template->param("raw_$param" => $params{$param}); + $template->param("raw_$param" => $value); } } - # This needs to run even in scan mode, in order to process - # links and other metadata includes via the template. - my $scan=! defined wantarray; - return IkiWiki::preprocess($params{page}, $params{destpage}, - IkiWiki::filter($params{page}, $params{destpage}, - $template->output), $scan); + IkiWiki::filter($params{page}, $params{destpage}, + $template->output), $scan); } 1 -- cgit v1.2.3