diff options
author | holger <holger@web> | 2016-09-07 08:20:55 -0400 |
---|---|---|
committer | admin <admin@branchable.com> | 2016-09-07 08:20:55 -0400 |
commit | 20e2f80ad4e4b767c981f3585a9d39faea689ba9 (patch) | |
tree | 55c227dd148f809c743aaa611dd0d97dc22a27e5 /doc/bugs | |
parent | afa42746044ef5b10cb94076882d394769933537 (diff) | |
download | ikiwiki-20e2f80ad4e4b767c981f3585a9d39faea689ba9.tar ikiwiki-20e2f80ad4e4b767c981f3585a9d39faea689ba9.tar.gz |
Diffstat (limited to 'doc/bugs')
-rw-r--r-- | doc/bugs/color_plugin_produces_artifacts_in_table-of-contents.mdwn | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/doc/bugs/color_plugin_produces_artifacts_in_table-of-contents.mdwn b/doc/bugs/color_plugin_produces_artifacts_in_table-of-contents.mdwn index 0a8ee99c7..f97e5c5db 100644 --- a/doc/bugs/color_plugin_produces_artifacts_in_table-of-contents.mdwn +++ b/doc/bugs/color_plugin_produces_artifacts_in_table-of-contents.mdwn @@ -34,44 +34,45 @@ This is the proposed patch to the second solution. Tested with the latest versio -diff --git a/IkiWiki/Plugin/toc.pm b/IkiWiki/Plugin/toc.pm -index ac07b9a..5c2b056 100644 ---- a/IkiWiki/Plugin/toc.pm -+++ b/IkiWiki/Plugin/toc.pm -@@ -57,6 +57,7 @@ sub format (@) { - my $startlevel=($params{startlevel} ? $params{startlevel} : 0); - my $curlevel=$startlevel-1; - my $liststarted=0; -+ my $headercollect=0; - my $indent=sub { "\t" x $curlevel }; - $p->handler(start => sub { - my $tagname=shift; -@@ -107,6 +108,7 @@ sub format (@) { - $index.=&$indent."<li class=\"L$curlevel\">". - "<a href=\"#$anchor\">"; - -+ $headercollect=1; - $p->handler(text => sub { - $page.=join("", @_); - $index.=join("", @_); -@@ -117,12 +119,17 @@ sub format (@) { - $p->handler(text => undef); - $p->handler(end => undef); - $index.="</a>\n"; -+ $headercollect=0; -+ } -+ else { -+ $index.=join("",@_); - } - $page.=join("", @_); - }, "tagname, text"); - } - else { - $page.=$text; -+ $index.=$text if ($headercollect); - } - }, "tagname, text"); - $p->handler(default => sub { $page.=join("", @_) }, "text"); + diff --git a/IkiWiki/Plugin/toc.pm b/IkiWiki/Plugin/toc.pm + index ac07b9a..5c2b056 100644 + --- a/IkiWiki/Plugin/toc.pm + +++ b/IkiWiki/Plugin/toc.pm + @@ -57,6 +57,7 @@ sub format (@) { + my $startlevel=($params{startlevel} ? $params{startlevel} : 0); + my $curlevel=$startlevel-1; + my $liststarted=0; + + my $headercollect=0; + my $indent=sub { "\t" x $curlevel }; + $p->handler(start => sub { + my $tagname=shift; + @@ -107,6 +108,7 @@ sub format (@) { + $index.=&$indent."<li class=\"L$curlevel\">". + "<a href=\"#$anchor\">"; + + + $headercollect=1; + $p->handler(text => sub { + $page.=join("", @_); + $index.=join("", @_); + @@ -117,12 +119,17 @@ sub format (@) { + $p->handler(text => undef); + $p->handler(end => undef); + $index.="</a>\n"; + + $headercollect=0; + + } + + else { + + $index.=join("",@_); + } + $page.=join("", @_); + }, "tagname, text"); + } + else { + $page.=$text; + + $index.=$text if ($headercollect); + } + }, "tagname, text"); + $p->handler(default => sub { $page.=join("", @_) }, "text"); + [[!tag patch]] |