From 99e5e6dd08ba193046a9e2c349ec5843d31c9c1c Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kodama.kitenet.net>
Date: Sat, 31 May 2008 15:10:23 -0400
Subject: [PATCH] inline: The optimisation in 2.41 broke nested inlines. Detect
 those and avoid overoptimising.

---
 IkiWiki/Plugin/inline.pm                       | 8 ++++++--
 debian/changelog                               | 2 ++
 doc/bugs/nested_inlines_produce_no_output.mdwn | 2 ++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 1fbd8b69c..7d81e9182 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -11,6 +11,7 @@ use URI;
 my %knownfeeds;
 my %page_numfeeds;
 my @inline;
+my $nested=0;
 
 sub import { #{{{
 	hook(type => "getopt", id => "inline", call => \&getopt);
@@ -329,7 +330,7 @@ sub preprocess_inline (@) { #{{{
 		}
 	}
 	
-	return $ret if $raw;
+	return $ret if $raw || $nested;
 	push @inline, $ret;
 	return "<div class=\"inline\" id=\"$#inline\"></div>\n\n";
 } #}}}
@@ -350,11 +351,14 @@ sub get_inline_content ($$) { #{{{
 	my $file=$pagesources{$page};
 	my $type=pagetype($file);
 	if (defined $type) {
-		return htmlize($page, $type,
+		$nested++;
+		my $ret=htmlize($page, $type,
 		       linkify($page, $destpage,
 		       preprocess($page, $destpage,
 		       filter($page, $destpage,
 		       readfile(srcfile($file))))));
+		$nested--;
+		return $ret;
 	}
 	else {
 		return "";
diff --git a/debian/changelog b/debian/changelog
index 1f24f7530..7a3f6061f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ ikiwiki (2.49) UNRELEASED; urgency=low
 
   * haiku: Generate valid xhtml.
   * ikiwiki-mass-rebuild: Don't trust $! when setting $)
+  * inline: The optimisation in 2.41 broke nested inlines. Detect those
+    and avoid overoptimising.
 
  -- Joey Hess <joeyh@debian.org>  Fri, 30 May 2008 19:08:54 -0400
 
diff --git a/doc/bugs/nested_inlines_produce_no_output.mdwn b/doc/bugs/nested_inlines_produce_no_output.mdwn
index c40a847b0..3f2fccdfb 100644
--- a/doc/bugs/nested_inlines_produce_no_output.mdwn
+++ b/doc/bugs/nested_inlines_produce_no_output.mdwn
@@ -8,3 +8,5 @@ If an inlined page itself contains an inline directive, the nested directive wil
 When rendered, _pets_ [contains](http://www.willthompson.co.uk/tmp/ikiwiki-nested-inline/output/pets/) the content from _pets/dogs_ and _pets/cats_, but not the pages inlined into them.  However, the subpages [correctly](http://www.willthompson.co.uk/tmp/ikiwiki-nested-inline/output/pets/dogs/) [include](http://www.willthompson.co.uk/tmp/ikiwiki-nested-inline/output/pets/cats/) their own children.
 
 This used to work in at least ikiwiki 1.45.  I stepped through `preprocess_inline`, but couldn't see why this wasn't working.
+
+> Broke due to overoptimisation, fixed now. [[done]] --[[Joey]]
-- 
2.39.5