aboutsummaryrefslogtreecommitdiff
path: root/doc/bugs/color_plugin_produces_artifacts_in_table-of-contents.mdwn
diff options
context:
space:
mode:
authorholger <holger@web>2016-03-12 11:32:35 -0400
committeradmin <admin@branchable.com>2016-03-12 11:32:35 -0400
commit2fe0b0551c28245957828adfc22a17c40e9eb999 (patch)
treed773b780de8991ff8a18aeac0b29e5adb9ebc734 /doc/bugs/color_plugin_produces_artifacts_in_table-of-contents.mdwn
parent4712595e6304cc224b2dfdbb1cfe9f2e61bed371 (diff)
downloadikiwiki-2fe0b0551c28245957828adfc22a17c40e9eb999.tar
ikiwiki-2fe0b0551c28245957828adfc22a17c40e9eb999.tar.gz
Diffstat (limited to 'doc/bugs/color_plugin_produces_artifacts_in_table-of-contents.mdwn')
-rw-r--r--doc/bugs/color_plugin_produces_artifacts_in_table-of-contents.mdwn24
1 files changed, 14 insertions, 10 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 487dbb51d..4eff651cd 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
@@ -21,7 +21,7 @@ Reason for this behaviour is:
There are a few possible solutions to this depending on how it should work:
1. The easiest thing would be to just add a "last" parameter to the toc plugin format hook (or "first" to the color plugin). Result: No color in tocs at all
-1. Adding four lines to toc.pm (and possibly removing ~4 now superfluous lines) would make it preserve ALL markup in headers, color as well as html markup or markdown (*emphasize* for example). Execution order of the plugins would not matter at all
+1. Adding four (**EDIT** seven) lines to toc.pm (and possibly removing ~4 now superfluous lines **EDIT** No) would make it preserve ALL markup in headers, color as well as html markup or markdown (*emphasize* for example). Execution order of the plugins would not matter at all
1. A bit more code would be necessary to just specifically preserve the color, but nothing else
I would propose implementing the second option because visual markers in headers are useful to convey additional information very fast and this information should be preserved in the toc. Example: Bug or task/project tracker with color conveying status of the bug or task.
@@ -34,10 +34,12 @@ This is the proposed patch to the second solution. I did not yet test it with th
The part that could probably be removed in toc is the handler call "$p->handler(text => sub {" in line 110. It collects all text in the header as HTML::Parser "dtext", which means entities are decoded in the text. Since that step is probably already done in ikiwiki or doesn't need to be done (otherwise ikiwiki with toc.pm disabled would not work correctly) I'm pretty sure the "dtext" is not necessary. And in that case the patch below would just collect that text in the default handler. Not tested at all, I want to hear a second opinion first.
+**EDIT** After testing the handler call is still necessary, but the "dtext" could be changed to "text". Also I needed to add 3 more lines, the patch below is up to date. It works with all markup and markdown I could think of. The only case not handled optimal is if the header is just a link and nothing else, then there is no text left for the local link, the toc links directly to a different page. Is that acceptable or not?
+
(Should I upload this patch as a branch to ikiwiki.info? Not sure about how patch submission works here)
- diff --git a/IkiWiki/Plugin/toc.pm b/IkiWiki/Plugin/toc.pm
- index ac07b9a..b75a184 100644
+ 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 (@) {
@@ -56,15 +58,17 @@ The part that could probably be removed in toc is the handler call "$p->handler(
$p->handler(text => sub {
$page.=join("", @_);
$index.=join("", @_);
- @@ -114,6 +116,7 @@ sub format (@) {
- $p->handler(end => sub {
- my $tagname=shift;
- if ($tagname =~ /^h(\d+)$/i) {
- + $headercollect=0;
+ @@ -117,12 +119,17 @@ sub format (@) {
$p->handler(text => undef);
$p->handler(end => undef);
$index.="</a>\n";
- @@ -123,6 +126,7 @@ sub format (@) {
+ + $headercollect=0;
+ + }
+ + else {
+ + $index.=join("",@_);
+ }
+ $page.=join("", @_);
+ }, "tagname, text");
}
else {
$page.=$text;
@@ -73,5 +77,5 @@ The part that could probably be removed in toc is the handler call "$p->handler(
}, "tagname, text");
$p->handler(default => sub { $page.=join("", @_) }, "text");
--
- 1.7.10.4
+ 1.8.4.5