aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/toc.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2007-11-23 11:40:02 -0500
committerJoey Hess <joey@kodama.kitenet.net>2007-11-23 11:40:02 -0500
commitc9c0f271b60e4a6ef8392cd3a5339d9c2368b494 (patch)
tree08dd0e236dff5678d45e257551e1c3c42b8a0b7b /IkiWiki/Plugin/toc.pm
parente72825619d14c68e9ad6a73c2c0d726056141f1f (diff)
downloadikiwiki-c9c0f271b60e4a6ef8392cd3a5339d9c2368b494.tar
ikiwiki-c9c0f271b60e4a6ef8392cd3a5339d9c2368b494.tar.gz
* toc: Handle html elements embedded inside a header, rather than
stopping collecting the header text at the first element.
Diffstat (limited to 'IkiWiki/Plugin/toc.pm')
-rw-r--r--IkiWiki/Plugin/toc.pm22
1 files changed, 15 insertions, 7 deletions
diff --git a/IkiWiki/Plugin/toc.pm b/IkiWiki/Plugin/toc.pm
index 070c07b0e..639cae4a9 100644
--- a/IkiWiki/Plugin/toc.pm
+++ b/IkiWiki/Plugin/toc.pm
@@ -86,17 +86,25 @@ sub format (@) { #{{{
}
$liststarted=0;
}
+
+ $index.=&$indent."</li>\n" unless $liststarted;
+ $liststarted=0;
+ $index.=&$indent."<li class=\"L$curlevel\">".
+ "<a href=\"#$anchor\">";
$p->handler(text => sub {
$page.=join("", @_);
- $index.=&$indent."</li>\n" unless $liststarted;
- $liststarted=0;
- $index.=&$indent."<li class=\"L$curlevel\">".
- "<a href=\"#$anchor\">".
- join("", @_).
- "</a>\n";
- $p->handler(text => undef);
+ $index.=join("", @_);
}, "dtext");
+ $p->handler(end => sub {
+ my $tagname=shift;
+ if ($tagname =~ /^h(\d+)$/i) {
+ $p->handler(text => undef);
+ $p->handler(end => undef);
+ $index.="</a>\n";
+ }
+ $page.=join("", @_);
+ }, "tagname, text");
}
else {
$page.=$text;