X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/4e5a14bad2338ff9bfb4c545b48437681b78870a..f36514d27f4975fcb38926f53b557c680cbb38fb:/doc/bugs/linkmap_displays_underscore_escapes.mdwn diff --git a/doc/bugs/linkmap_displays_underscore_escapes.mdwn b/doc/bugs/linkmap_displays_underscore_escapes.mdwn index 6d96e463b..14164d076 100644 --- a/doc/bugs/linkmap_displays_underscore_escapes.mdwn +++ b/doc/bugs/linkmap_displays_underscore_escapes.mdwn @@ -1,3 +1,5 @@ +[[!template id=gitbranch branch=chrysn/linkmapenhancement author="[[chrysn]]"]] + [[ikiwiki/directive/linkmap]]s display the file name instead of the pagetitle, showing unsightly underscore escapes and underscores instead of blanks to users. the attached [[!taglink patch]] fixes this; from its commit message: @@ -13,75 +15,21 @@ the attached [[!taglink patch]] fixes this; from its commit message: because it can represent the '\"' dyad properly, and because it doesn't need special-casing of newlines). -everything below that line is the patch as produced by git-format-patch. (btw, what's the preferred way to send patches, apart from creating a git branch somewhere?) - ---------- snap ------------
+the output will look much better (at least in my wikis) with the "[[bugs/pagetitle function does not respect meta titles]]" issue fixed. -From efbb1121ffdc146f5c9a481a51f23ad151b9f240 Mon Sep 17 00:00:00 2001 -From: chrysn-Date: Thu, 15 Mar 2012 14:38:42 +0100 -Subject: [PATCH] display the pagetitle() in linkmaps +> [[Looks good to me|users/smcv/ready]]. +> +> I don't think it's correct for `pagetitle()` to output `\[[!meta title]]` +> though, as discussed on the linked bug: it appears in an assortment of +> contexts where the full formal title of the page seems inappropriate. +> If you want linkmap to use `\[[!meta title]]`, I think it would be +> better to give it a `show` parameter, like `\[[!map]]` has? +> --[[smcv]] -without this patch, linkmaps display underscores and underscore escape -sequences in the rendered output. +>> sounds good; i'll have a look at it the next time i touch the linkmap +>> plugin. the patch at hand would be a starting point for that. --[[chrysn]] -this introduces a pageescape function, which invoces pagetitle() to get -rid of underscore escapes and wraps the resulting utf8 string -appropriately for inclusion in a dot file (using dot's html encoding -because it can represent the '\"' dyad properly, and because it doesn't -need special-casing of newlines). ---- - IkiWiki/Plugin/linkmap.pm | 17 +++++++++++++++-- - 1 files changed, 15 insertions(+), 2 deletions(-) +the patch is stored in [[the patch.pl]] as created by git-format-patch, and can +be pulled from the abovementioned branch. -diff --git a/IkiWiki/Plugin/linkmap.pm b/IkiWiki/Plugin/linkmap.pm -index ac26e07..b5ef1a1 100644 ---- a/IkiWiki/Plugin/linkmap.pm -+++ b/IkiWiki/Plugin/linkmap.pm -@@ -5,6 +5,7 @@ use warnings; - use strict; - use IkiWiki 3.00; - use IPC::Open2; -+use HTML::Entities; - - sub import { - hook(type => "getsetup", id => "linkmap", call => \&getsetup); -@@ -22,6 +23,18 @@ sub getsetup () { - - my $mapnum=0; - -+sub pageescape { -+ my $item = shift; -+ # encoding explicitly in case ikiwiki is configured to accept <> or & -+ # in file names -+ my $title = pagetitle($item, 1); -+ # it would not be necessary to encode *all* the html entities (<> would -+ # be sufficient, &" probably a good idea), as dot accepts utf8, but it -+ # isn't bad either -+ $title = encode_entities($title); -+ return("<$title>"); -+} -+ - sub preprocess (@) { - my %params=@_; - -@@ -63,7 +76,7 @@ sub preprocess (@) { - my $show=sub { - my $item=shift; - if (! $shown{$item}) { -- print OUT "\"$item\" [shape=box,href=\"$mapitems{$item}\"];\n"; -+ print OUT pageescape($item)." [shape=box,href=\"$mapitems{$item}\"];\n"; - $shown{$item}=1; - } - }; -@@ -74,7 +87,7 @@ sub preprocess (@) { - foreach my $endpoint ($item, $link) { - $show->($endpoint); - } -- print OUT "\"$item\" -> \"$link\";\n"; -+ print OUT pageescape($item)." -> ".pageescape($link).";\n"; - } - } - print OUT "}\n"; --- -1.7.9.1 +> update 2014-06-29: branch still merges cleanly and works. --[[chrysn]]