diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-11-02 20:45:29 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-11-02 20:45:29 +0100 |
commit | 1d1990fe6d6358a34093b59432f3ad48b46a8d48 (patch) | |
tree | 9694548c9980cb580bb8d7ef54610535b26f0633 | |
parent | Use manProvider from config. (diff) | |
download | vimwiki-scripts-0.1.1.tar.gz vimwiki-scripts-0.1.1.tar.xz |
Prettier man links.v0.1.1
-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) |