From 1d1990fe6d6358a34093b59432f3ad48b46a8d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 2 Nov 2022 20:45:29 +0100 Subject: Prettier man links. --- hs/src/Vimwiki/Man.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hs/src/Vimwiki/Man.hs b/hs/src/Vimwiki/Man.hs index 35d6383..fca432d 100644 --- a/hs/src/Vimwiki/Man.hs +++ b/hs/src/Vimwiki/Man.hs @@ -13,13 +13,18 @@ import Text.Pandoc (Inline (Str)) import Util (nullToMaybe) import Data.Text.Compat +-- expands [[man:page#1]] to page (1) +-- expands [[man:page#1|Pretty]] to Pretty (page (1)) manRewriter :: (PandocStr -> Maybe PandocStr -> Maybe PandocStr -> PandocStr) -> [Inline] -> URI -> ([Inline], PandocStr) -manRewriter manImpl _ uri - = ([Str . conv $ path <> "(" <> (fromMaybe "?" section') <> ")"] +manRewriter manImpl body uri + = (handle body $ path <> "(" <> (fromMaybe "?" section') <> ")" , manImpl path section' language') where path :: PandocStr path = conv $ uriPath uri + handle :: PS a => [Inline] -> a -> [Inline] + handle [] s = [Str . conv $ s] + handle xs s = xs <> [Str " (", Str . conv $ s, Str ")"] section' = conv . tail <$> nullToMaybe (uriFragment uri) language' = conv . tail <$> nullToMaybe (uriQuery uri) -- cgit v1.2.3