diff options
-rw-r--r-- | hs/src/Vimwiki/Man.hs | 9 |
1 files 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 <a href="<?man-url?>">page (1)</a> +-- expands [[man:page#1|Pretty]] to <a href="<?man-url?>">Pretty (page (1))</a> 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) |